<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- saved from url=(0104)http://www.ogre3d.org/tikiwiki/tiki-index.php?page=3rd+person+camera+system+tutorial&structure=Tutorials -->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" id="page_170" lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">


<meta http-equiv="Content-Script-Type" content="text/javascript">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta name="generator" content="Tiki Wiki CMS Groupware - http://tiki.org">
	<meta name="keywords" content="Ogre, Ogre3d, wiki, support camera camerasystem thirdperson snippet tutorial  ">


<title>3rd person camera system tutorial</title>

	<link rel="icon" href="http://www.ogre3d.org/tikiwiki/ogrefavicon.ico">


	<link rel="StyleSheet" href="test_files/layerstreemenu.css" type="text/css">
<link rel="StyleSheet" href="test_files/layerstreemenu-hidden.css" type="text/css">
<script type="text/javascript">
<!--//--><![CDATA[//><!--
var numl;var toBeHidden;// PHP Layers Menu 3.2.0-rc (C) 2001-2004 Marco Pratesi - http://www.marcopratesi.it/

DOM = (document.getElementById) ? 1 : 0;
NS4 = (document.layers) ? 1 : 0;
// We need to explicitly detect Konqueror
// because Konqueror 3 sets IE = 1 ... AAAAAAAAAARGHHH!!!
Konqueror = (navigator.userAgent.indexOf('Konqueror') > -1) ? 1 : 0;
// We need to detect Konqueror 2.2 as it does not handle the window.onresize event
Konqueror22 = (navigator.userAgent.indexOf('Konqueror 2.2') > -1 || navigator.userAgent.indexOf('Konqueror/2.2') > -1) ? 1 : 0;
Konqueror30 =
	(
		navigator.userAgent.indexOf('Konqueror 3.0') > -1
		|| navigator.userAgent.indexOf('Konqueror/3.0') > -1
		|| navigator.userAgent.indexOf('Konqueror 3;') > -1
		|| navigator.userAgent.indexOf('Konqueror/3;') > -1
		|| navigator.userAgent.indexOf('Konqueror 3)') > -1
		|| navigator.userAgent.indexOf('Konqueror/3)') > -1
	)
	? 1 : 0;
Konqueror31 = (navigator.userAgent.indexOf('Konqueror 3.1') > -1 || navigator.userAgent.indexOf('Konqueror/3.1') > -1) ? 1 : 0;
// We need to detect Konqueror 3.2 and 3.3 as they are affected by the see-through effect only for 2 form elements
Konqueror32 = (navigator.userAgent.indexOf('Konqueror 3.2') > -1 || navigator.userAgent.indexOf('Konqueror/3.2') > -1) ? 1 : 0;
Konqueror33 = (navigator.userAgent.indexOf('Konqueror 3.3') > -1 || navigator.userAgent.indexOf('Konqueror/3.3') > -1) ? 1 : 0;
Opera = (navigator.userAgent.indexOf('Opera') > -1) ? 1 : 0;
Opera5 = (navigator.userAgent.indexOf('Opera 5') > -1 || navigator.userAgent.indexOf('Opera/5') > -1) ? 1 : 0;
Opera6 = (navigator.userAgent.indexOf('Opera 6') > -1 || navigator.userAgent.indexOf('Opera/6') > -1) ? 1 : 0;
Opera56 = Opera5 || Opera6;
IE = (navigator.userAgent.indexOf('MSIE') > -1) ? 1 : 0;
IE = IE && !Opera;
IE5 = IE && DOM;
IE4 = (document.all) ? 1 : 0;
IE4 = IE4 && IE && !DOM;

//--><!]]>
</script>







		
<link rel="stylesheet" href="test_files/minified_b332e08069a82e77347b37a40dc356b7.css" type="text/css" media="screen">
<link rel="stylesheet" href="test_files/minified_b332e08069a82e77347b37a40dc356b7.css" type="text/css" media="print">
<!--[if lt IE 7]>
<link rel="stylesheet" href="css/ie6.css" type="text/css" />
<link rel="stylesheet" href="styles/ogre/ie6.css" type="text/css" />
<![endif]-->
<!--[if IE 7]>
<link rel="stylesheet" href="css/ie7.css" type="text/css" />
<link rel="stylesheet" href="styles/ogre/ie7.css" type="text/css" />
<![endif]-->
<!--[if IE 8]>
<link rel="stylesheet" href="css/ie8.css" type="text/css" />
<![endif]-->

</head>
	<body class="tiki tiki_wiki_page"><div id="cboxOverlay" style="display: none;"></div><div id="colorbox" class="" style="padding-bottom: 42px; padding-right: 42px; display: none;"><div id="cboxWrapper"><div><div id="cboxTopLeft" style="float: left;"></div><div id="cboxTopCenter" style="float: left;"></div><div id="cboxTopRight" style="float: left;"></div></div><div style="clear:left"><div id="cboxMiddleLeft" style="float: left;"></div><div id="cboxContent" style="float: left;"><div id="cboxLoadedContent" style="width: 0px; height: 0px; overflow: hidden;" class=""></div><div id="cboxLoadingOverlay" class=""></div><div id="cboxLoadingGraphic" class=""></div><div id="cboxTitle" class=""></div><div id="cboxCurrent" class=""></div><div id="cboxNext" class=""></div><div id="cboxPrevious" class=""></div><div id="cboxSlideshow" class=""></div><div id="cboxClose" class=""></div></div><div id="cboxMiddleRight" style="float: left;"></div></div><div style="clear:left"><div id="cboxBottomLeft" style="float: left;"></div><div id="cboxBottomCenter" style="float: left;"></div><div id="cboxBottomRight" style="float: left;"></div></div></div><div style="position:absolute; width:9999px; visibility:hidden; display:none"></div></div>
		<ul class="jumplinks" style="position:absolute;top:-9000px;left:-9000px;z-index:9;">
			<li><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=3rd+person+camera+system+tutorial&amp;structure=Tutorials#tiki-center">Jump to Content</a></li>
		</ul>

		<div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>
<script type="text/javascript" language="JavaScript" src="test_files/overlib.js"></script>




	<div id="fixedwidth"> 
					<div id="main-shadow">
			<div id="cluetip-waitimage" style="position: absolute; display: none;"></div><div id="cluetip" style="display: none; position: absolute;"><div style="z-index: 1999; opacity: 0.1; top: 1px; left: 1px; position: absolute; background-color: rgb(0, 0, 0);"></div><div style="z-index: 1999; opacity: 0.1; top: 2px; left: 2px; position: absolute; background-color: rgb(0, 0, 0);"></div><div style="z-index: 1999; opacity: 0.1; top: 3px; left: 3px; position: absolute; background-color: rgb(0, 0, 0);"></div><div style="z-index: 1999; opacity: 0.1; top: 4px; left: 4px; position: absolute; background-color: rgb(0, 0, 0);"></div><div style="z-index: 1999; opacity: 0.1; top: 5px; left: 5px; position: absolute; background-color: rgb(0, 0, 0);"></div><div style="z-index: 1999; opacity: 0.1; top: 6px; left: 6px; position: absolute; background-color: rgb(0, 0, 0);"></div><div id="cluetip-outer" style="position: relative; z-index: 2000;"><h3 id="cluetip-title"></h3><div id="cluetip-inner"></div></div><div id="cluetip-extra"></div><div id="cluetip-arrows" class="cluetip-arrows"></div></div><div id="main">
									<div id="header-shadow">
								<div class="clearfix" id="header">
		
				<div class="clearfix" id="siteheader">
		




<div class="clearfix" id="header-top">



		



			<div class="clearfix" id="sioptions">
																<div id="customcode" class="floatright">
						<div style="float:right;"><a href="http://www.ogre3d.org/forums/" title="Ogre Forums">Ogre Forums</a>&nbsp;&nbsp;<a href="http://www.ogre3d.org/" title="ogre3d.org">ogre3d.org</a></div>
					</div>
								<div id="sitelogo" class="floatleft">
					<a href="http://www.ogre3d.org/tikiwiki/" title="Ogre Wiki"><img src="test_files/site_logo.gif" alt="Ogre Wiki"></a>				</div>
									<div id="sitetitles" class="floatleft">
							<div id="sitetitle">
		<a href="http://www.ogre3d.org/tikiwiki/">Ogre Wiki</a>	</div>
	<div id="sitesubtitle">
		 Support and community documentation for Ogre3D 	</div>

					</div>
							
					</div>
	
	
		

	
	









<div id="siteloginbar"><a href="http://www.ogre3d.org/tikiwiki/tiki-login.php" title="Login">Login</a></div>
<!--[if IE]><br style="clear:both; height: 0" /><![endif]-->
</div>

<div class="clearfix" id="tiki-top">

	

			<div class="role_navigation">
			<ul id="cssmenu1" class="cssmenu_horiz menu43 sf-js-enabled sf-shadow"><li class="option182 menuOption menuLevel0"><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Home"><span class="menuText">Home</span></a></li><li class="option183 menuSection menuSection0 menuLevel0"><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Tutorials" class="sf-with-ul"><span class="menuText">Tutorials</span><span class="sf-sub-indicator"> »</span></a><ul style="float: none; width: 14.8333em; display: none; visibility: hidden;"><li class="option383 menuOption menuLevel1" style="white-space: normal; float: left; width: 100%;"><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Tutorials" style="float: none; width: auto;"><span class="menuText">Tutorials Home</span></a></li><li class="option192 menuOption menuLevel1" style="white-space: normal; float: left; width: 100%;"><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Basic%20Tutorials" style="float: none; width: auto;"><span class="menuText">Basic Tutorials</span></a></li><li class="option194 menuOption menuLevel1" style="white-space: normal; float: left; width: 100%;"><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Intermediate%20Tutorials" style="float: none; width: auto;"><span class="menuText">Intermediate Tutorials</span></a></li><li class="option402 menuOption menuLevel1" style="white-space: normal; float: left; width: 100%;"><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Mad%20Marx%20Tutorials" style="float: none; width: auto;"><span class="menuText">Mad Marx Tutorials</span></a></li><li class="option212 menuOption menuLevel1" style="white-space: normal; float: left; width: 100%;"><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=In%20Depth%20Tutorials" style="float: none; width: auto;"><span class="menuText">In Depth Tutorials</span></a></li><li class="option285 menuOption menuLevel1" style="white-space: normal; float: left; width: 100%;"><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Older%20Tutorials" style="float: none; width: auto;"><span class="menuText">Older Tutorials</span></a></li><li class="option382 menuOption menuLevel1" style="white-space: normal; float: left; width: 100%;"><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=External%20Tutorials" style="float: none; width: auto;"><span class="menuText">External Tutorials</span></a></li></ul></li><li class="option184 menuSection menuSection0 menuLevel0"><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Cookbook" class="sf-with-ul"><span class="menuText">Cookbook</span><span class="sf-sub-indicator"> »</span></a><ul style="float: none; width: 11.1667em; display: none; visibility: hidden;"><li class="option384 menuOption menuLevel1" style="white-space: normal; float: left; width: 100%;"><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Cookbook" style="float: none; width: auto;"><span class="menuText">Cookbook Home</span></a></li><li class="option265 menuOption menuLevel1" style="white-space: normal; float: left; width: 100%;"><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=CodeBank" style="float: none; width: auto;"><span class="menuText">CodeBank</span></a></li><li class="option266 menuOption menuLevel1" style="white-space: normal; float: left; width: 100%;"><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Snippets" style="float: none; width: auto;"><span class="menuText">Snippets</span></a></li><li class="option267 menuOption menuLevel1" style="white-space: normal; float: left; width: 100%;"><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Experiences" style="float: none; width: auto;"><span class="menuText">Experiences</span></a></li><li class="option268 menuOption menuLevel1" style="white-space: normal; float: left; width: 100%;"><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=OgreArticles" style="float: none; width: auto;"><span class="menuText">Ogre Articles</span></a></li></ul></li><li class="option185 menuSection menuSection0 menuLevel0"><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Libraries" class="sf-with-ul"><span class="menuText">Libraries</span><span class="sf-sub-indicator"> »</span></a><ul style="float: none; width: 14.75em; display: none; visibility: hidden;"><li class="option385 menuOption menuLevel1" style="white-space: normal; float: left; width: 100%;"><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Libraries" style="float: none; width: auto;"><span class="menuText">Libraries Home</span></a></li><li class="option274 menuOption menuLevel1" style="white-space: normal; float: left; width: 100%;"><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Alternative%20Languages" style="float: none; width: auto;"><span class="menuText">Alternative Languages</span></a></li><li class="option273 menuSection menuSection1 menuLevel1" style="white-space: normal; float: left; width: 100%;"><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Assembling%20A%20Toolset" style="float: none; width: auto;" class="sf-with-ul"><span class="menuText">Assembling A Toolset</span><span class="sf-sub-indicator"> »</span></a><ul style="left: 14.75em; float: none; width: 12.8333em; display: none; visibility: hidden;"><li class="option406 menuOption menuLevel2" style="white-space: normal; float: left; width: 100%;"><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Development+Tools" style="float: none; width: auto;"><span class="menuText">Development Tools</span></a></li><li class="option276 menuOption menuLevel2" style="white-space: normal; float: left; width: 100%;"><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=OGRE+Libraries" style="float: none; width: auto;"><span class="menuText">OGRE Libraries</span></a></li><li class="option407 menuOption menuLevel2" style="white-space: normal; float: left; width: 100%;"><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=List+Of+Libraries" style="float: none; width: auto;"><span class="menuText">List of Libraries</span></a></li></ul></li></ul></li><li class="option190 menuSection menuSection0 menuLevel0"><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Tools" class="sf-with-ul"><span class="menuText">Tools</span><span class="sf-sub-indicator"> »</span></a><ul style="float: none; width: 20em; display: none; visibility: hidden;"><li class="option386 menuOption menuLevel1" style="white-space: normal; float: left; width: 100%;"><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Tools" style="float: none; width: auto;"><span class="menuText">Tools Home</span></a></li><li class="option277 menuOption menuLevel1" style="white-space: normal; float: left; width: 100%;"><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=DCC%20Tools" style="float: none; width: auto;"><span class="menuText">DCC Tools</span></a></li><li class="option269 menuOption menuLevel1" style="white-space: normal; float: left; width: 100%;"><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=DCC%20Tutorials" style="float: none; width: auto;"><span class="menuText">DCC Tutorials</span></a></li><li class="option270 menuOption menuLevel1" style="white-space: normal; float: left; width: 100%;"><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=DCC%20Articles" style="float: none; width: auto;"><span class="menuText">DCC Articles</span></a></li><li class="option271 menuOption menuLevel1" style="white-space: normal; float: left; width: 100%;"><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=DCC%20Resources" style="float: none; width: auto;"><span class="menuText">DCC Resources</span></a></li><li class="option272 menuOption menuLevel1" style="white-space: normal; float: left; width: 100%;"><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Assembling%20a%20production%20pipeline" style="float: none; width: auto;"><span class="menuText">Assembling a production pipeline</span></a></li></ul></li><li class="option189 menuSection menuSection0 menuLevel0"><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Development" class="sf-with-ul"><span class="menuText">Development</span><span class="sf-sub-indicator"> »</span></a><ul style="float: none; width: 19.0833em; display: none; visibility: hidden;"><li class="option387 menuOption menuLevel1" style="white-space: normal; float: left; width: 100%;"><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Development" style="float: none; width: auto;"><span class="menuText">Development Home</span></a></li><li class="option201 menuOption menuLevel1" style="white-space: normal; float: left; width: 100%;"><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Roadmap" style="float: none; width: auto;"><span class="menuText">Roadmap</span></a></li><li class="option202 menuOption menuLevel1" style="white-space: normal; float: left; width: 100%;"><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Building%20Ogre" style="float: none; width: auto;"><span class="menuText">Building Ogre</span></a></li><li class="option292 menuOption menuLevel1" style="white-space: normal; float: left; width: 100%;"><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Installing%20the%20Ogre%20SDK" style="float: none; width: auto;"><span class="menuText">Installing the Ogre SDK</span></a></li><li class="option293 menuOption menuLevel1" style="white-space: normal; float: left; width: 100%;"><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Setting%20Up%20An%20Application" style="float: none; width: auto;"><span class="menuText">Setting Up An Application</span></a></li><li class="option395 menuOption menuLevel1" style="white-space: normal; float: left; width: 100%;"><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Ogre%20Wiki%20Tutorial%20Framework" style="float: none; width: auto;"><span class="menuText">Ogre Wiki Tutorial Framework</span></a></li><li class="option287 menuOption menuLevel1" style="white-space: normal; float: left; width: 100%;"><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Frequently%20Asked%20Questions" style="float: none; width: auto;"><span class="menuText">Frequently Asked Questions</span></a></li><li class="option208 menuOption menuLevel1" style="white-space: normal; float: left; width: 100%;"><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Google%20Summer%20Of%20Code" style="float: none; width: auto;"><span class="menuText">Google Summer Of Code</span></a></li><li class="option210 menuOption menuLevel1" style="white-space: normal; float: left; width: 100%;"><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Help%20Requested" style="float: none; width: auto;"><span class="menuText">Help Requested</span></a></li><li class="option283 menuOption menuLevel1" style="white-space: normal; float: left; width: 100%;"><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Ogre%20Core%20Articles" style="float: none; width: auto;"><span class="menuText">Ogre Core Articles</span></a></li></ul></li><li class="option187 menuSection menuSection0 menuLevel0"><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Community" class="sf-with-ul"><span class="menuText">Community</span><span class="sf-sub-indicator"> »</span></a><ul style="float: none; width: 15.25em; display: none; visibility: hidden;"><li class="option388 menuOption menuLevel1" style="white-space: normal; float: left; width: 100%;"><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Community" style="float: none; width: auto;"><span class="menuText">Community Home</span></a></li><li class="option261 menuOption menuLevel1" style="white-space: normal; float: left; width: 100%;"><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Projects%20Using%20OGRE" style="float: none; width: auto;"><span class="menuText">Projects Using Ogre</span></a></li><li class="option279 menuOption menuLevel1" style="white-space: normal; float: left; width: 100%;"><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Recommended%20reading" style="float: none; width: auto;"><span class="menuText">Recommended Reading</span></a></li><li class="option286 menuOption menuLevel1" style="white-space: normal; float: left; width: 100%;"><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Contractors" style="float: none; width: auto;"><span class="menuText">Contractors</span></a></li><li class="option262 menuSection menuSection1 menuLevel1" style="white-space: normal; float: left; width: 100%;"><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Wiki" style="float: none; width: auto;" class="sf-with-ul"><span class="menuText">Wiki</span><span class="sf-sub-indicator"> »</span></a><ul style="left: 15.25em; float: none; width: 16.5em; display: none; visibility: hidden;"><li class="option256 menuOption menuLevel2" style="white-space: normal; float: left; width: 100%;"><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Immediate%20Wiki%20Tasklist" style="float: none; width: auto;"><span class="menuText">Immediate Wiki Tasklist</span></a></li><li class="option391 menuOption menuLevel2" style="white-space: normal; float: left; width: 100%;"><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Wiki%20Ideas" style="float: none; width: auto;"><span class="menuText">Wiki Ideas</span></a></li><li class="option254 menuOption menuLevel2" style="white-space: normal; float: left; width: 100%;"><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Wiki%20Guidelines" style="float: none; width: auto;"><span class="menuText">Wiki Guidelines</span></a></li><li class="option284 menuOption menuLevel2" style="white-space: normal; float: left; width: 100%;"><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Article%20Writing%20Guidelines" style="float: none; width: auto;"><span class="menuText">Article Writing Guidelines</span></a></li><li class="option263 menuOption menuLevel2" style="white-space: normal; float: left; width: 100%;"><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Wiki%20Styles" style="float: none; width: auto;"><span class="menuText">Wiki Styles</span></a></li><li class="option282 menuOption menuLevel2" style="white-space: normal; float: left; width: 100%;"><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Wiki%20Tracker" style="float: none; width: auto;"><span class="menuText">Wiki Page Tracker</span></a></li></ul></li></ul></li></ul>
</div><div class="role_navigation">
			<ul id="cssmenu2" class="cssmenu_horiz menu50 sf-js-enabled sf-shadow"><li class="option396 menuSection menuSection0 menuLevel0"><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Ogre%20Wiki%20Help" class="sf-with-ul"><span class="menuText">Ogre Wiki Help</span><span class="sf-sub-indicator"> »</span></a><ul style="float: none; width: 17.8333em; display: none; visibility: hidden;"><li class="option397 menuOption menuLevel1" style="white-space: normal; float: left; width: 100%;"><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Ogre%20Wiki%20Help" style="float: none; width: auto;"><span class="menuText">Ogre Wiki Help Overview</span></a></li><li class="option398 menuOption menuLevel1" style="white-space: normal; float: left; width: 100%;"><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Help%20-%20Basic%20Syntax" style="float: none; width: auto;"><span class="menuText">Help - Basic Syntax</span></a></li><li class="option399 menuOption menuLevel1" style="white-space: normal; float: left; width: 100%;"><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Help%20-%20Images" style="float: none; width: auto;"><span class="menuText">Help - Images</span></a></li><li class="option400 menuOption menuLevel1" style="white-space: normal; float: left; width: 100%;"><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Help%20-%20Pages%20and%20Structures" style="float: none; width: auto;"><span class="menuText">Help - Pages and Structures</span></a></li><li class="option401 menuOption menuLevel1" style="white-space: normal; float: left; width: 100%;"><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Help%20-%20Wiki%20Plugins" style="float: none; width: auto;"><span class="menuText">Help - Wiki Plugins</span></a></li></ul></li></ul>
</div><div class="role_navigation">
</div><div class="role_navigation">
			<ul id="cssmenu4" class="cssmenu_horiz menu45 sf-js-enabled sf-shadow"><li class="option390 menuSection menuSection0 menuLevel0"><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=3rd+person+camera+system+tutorial&amp;structure=Tutorials" class="sf-with-ul"><span class="menuText">Toolbox</span><span class="sf-sub-indicator"> »</span></a><ul style="float: none; width: 11em; display: none; visibility: hidden;"><li class="option239 menuOption menuLevel1" style="white-space: normal; float: left; width: 100%;"><a href="http://www.ogre3d.org/tikiwiki/tiki-browse_freetags.php" style="float: none; width: auto;"><span class="menuText">Freetags</span></a></li><li class="option240 menuOption menuLevel1" style="white-space: normal; float: left; width: 100%;"><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=categories" style="float: none; width: auto;"><span class="menuText">Categories</span></a></li><li class="option241 menuOption menuLevel1" style="white-space: normal; float: left; width: 100%;"><a href="http://www.ogre3d.org/tikiwiki/tiki-listpages.php" style="float: none; width: auto;"><span class="menuText">List Pages</span></a></li><li class="option243 menuOption menuLevel1" style="white-space: normal; float: left; width: 100%;"><a href="http://www.ogre3d.org/tikiwiki/tiki-admin_structures.php" style="float: none; width: auto;"><span class="menuText">Structures</span></a></li><li class="option244 menuOption menuLevel1" style="white-space: normal; float: left; width: 100%;"><a href="http://www.ogre3d.org/tikiwiki/tiki-list_trackers.php" style="float: none; width: auto;"><span class="menuText">Trackers</span></a></li><li class="option260 menuOption menuLevel1" style="white-space: normal; float: left; width: 100%;"><a href="http://www.ogre3d.org/tikiwiki/tiki-list_file_gallery.php" style="float: none; width: auto;"><span class="menuText">List Galleries</span></a></li><li class="option281 menuOption menuLevel1" style="white-space: normal; float: left; width: 100%;"><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Ogre%20Lexicon" style="float: none; width: auto;"><span class="menuText">Ogre Lexicon</span></a></li><li class="option392 menuOption menuLevel1" style="white-space: normal; float: left; width: 100%;"><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Comments" style="float: none; width: auto;"><span class="menuText">Comments</span></a></li><li class="option394 menuOption menuLevel1" style="white-space: normal; float: left; width: 100%;"><a href="http://www.ogre3d.org/tikiwiki/tiki-shoutbox.php" style="float: none; width: auto;"><span class="menuText">Shoutbox</span></a></li></ul></li></ul>
</div><div class="role_navigation">
</div>
	


</div>				</div>
			</div></div>
			<div id="middle-shadow"><div class="clearfix" id="middle">
				<div class="clearfix nofullscreen" id="c1c2">
					<div class="clearfix" id="wrapper">
						<div id="col1" class=" marginright">

								<div class="clearfix" id="showhide_columns">
												<div class="clearfix" style="text-align:right;float:right">
									<a class="flip" href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=3rd+person+camera+system+tutorial&amp;structure=Tutorials#" onclick="toggleCols('col3','right'); return false"><img src="test_files/orightcol.png" alt="[Show/Hide Right Column]" class="colflip" style="border: none" title="[Show/Hide Right Column]" width="16" height="16"></a>
								</div>
										<br style="clear:both">
							</div>
	

							<div id="tiki-center-shadow"><div class="site_notice"><b><i>Welcome to the new Ogre Wiki!</i></b><br>If you haven't done so already, be sure to visit the <a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Wiki">Wiki Portal</a> to read about how the wiki works. Especially the <a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Ogre+Wiki+Overview">Ogre Wiki Overview</a> page.</div>


<div id="tiki-center" class="clearfix content">
							<div role="main" id="role_main">
 
	
 



 

	<div class="wikitopline clearfix" style="clear: both;">
	<div class="content">
				<div class="wikiinfo" style="float: left">

	<a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=3rd%20person%20camera%20system%20tutorial" class="titletop">3rd person camera system tutorial</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;


How to create a basic, flexible camera system

		</div>
		<div class="wikiactions" style="float: right; padding-left:10px; white-space: nowrap">
			<div class="icons" style="float: left;">
									<a title="Print" href="http://www.ogre3d.org/tikiwiki/tiki-print.php?page_ref_id=1931&amp;page=3rd%20person%20camera%20system%20tutorial"><img src="test_files/printer.png" alt="Print" style="border: none" title="Print" class="icon" width="16" height="16"></a>
	
								</div><!-- END of icons -->

				<form action="http://www.ogre3d.org/tikiwiki/tiki-index.php" method="get" style="display: block; float: left">
				<select name="page" onchange="this.form.submit()" title="Backlinks">
					<option selected="selected">Backlinks...</option>
							<option value="User:Kencho" title="User:Kencho">
					User:Kencho					</option>
							<option value="Simple 3rd person camera" title="Simple 3rd person camera">
					Simple 3rd person camera					</option>
						</select>
			</form>
	
				<form action="http://www.ogre3d.org/tikiwiki/tiki-index.php" method="post" style="float: left">
				<select name="page_ref_id" onchange="this.form.submit()">
					<option>Structures...</option>
							<option value="1931" selected="selected">
					Tutorials
							</option>
							<option value="1109">
					Cookbook
							</option>
						</select>
			</form>
	
			</div>
 
 
	</div> 
</div> 
	


	
<div id="top" class="wikitext clearfix nopagetitle">
			
		
		
					<div class="tocnav">
	<div class="clearfix">
		<div style="float: left; width: 100px">
  
        	<a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Tutorials&amp;structure=Tutorials&amp;page_ref_id=1"><img src="test_files/house.png" alt="TOC" title="Tutorials" style="border: none" class="icon" width="16" height="16"></a>    
        	<a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Simple+3rd+person+camera&amp;structure=Tutorials">
    		<img src="test_files/resultset_previous.png" alt="Previous page" title="Simple 3rd person camera" style="border: none" class="icon" width="16" height="16">
    	</a>
    
        	<a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=In+Depth+Tutorials&amp;structure=Tutorials">
    		<img src="test_files/resultset_up.png" alt="Parent page" title="In Depth Tutorials" style="border: none" class="icon" width="16" height="16">
    	</a>
    
    <a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Basic+Ogre+Framework&amp;structure=Tutorials"><img src="test_files/resultset_next.png" alt="Next page" title="Basic Ogre Framework" style="border: none" class="icon" width="16" height="16"></a>
		</div>
  		<div style="float: left;">
		</div>
	</div>
  	<div>
  	<a title="Structure (3.3)" href="http://www.ogre3d.org/tikiwiki/tiki-edit_structure.php?page=3rd+person+camera+system+tutorial&amp;page_ref_id=1"><img src="test_files/chart_organisation.png" alt="Structure" title="Structure (3.3)" style="border: none" class="icon" width="16" height="16"></a>&nbsp;&nbsp;
          	  <a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Tutorials&amp;structure=Tutorials">
              Tutorials
	  	  </a>
	      &nbsp;»&nbsp;	  <a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=In+Depth+Tutorials&amp;structure=Tutorials">
              In Depth Tutorials
	  	  </a>
	      &nbsp;»&nbsp;	  <a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=3rd+person+camera+system+tutorial&amp;structure=Tutorials">
              3rd person camera system tutorial
	  	  </a>
		</div>
</div>		
		
			 

	
			<p>Eihort(1.4)|Source
<br></p><div id="toc"><div id="toctitle"><h3>Table of contents</h3></div><ul class="toc"><ul><li><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=3rd+person+camera+system+tutorial&amp;structure=Tutorials#The_idea" class="link">The idea</a>
<ul><li><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=3rd+person+camera+system+tutorial&amp;structure=Tutorials#rd_person_camera_-_Chasing" class="link">3rd person camera - Chasing</a>
</li><li><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=3rd+person+camera+system+tutorial&amp;structure=Tutorials#rd_person_camera_-_Fixed" class="link">3rd person camera - Fixed</a>
</li><li><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=3rd+person+camera+system+tutorial&amp;structure=Tutorials#st_person_camera" class="link">1st person camera</a>
</li></ul></li><li><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=3rd+person+camera+system+tutorial&amp;structure=Tutorials#Important_things_to_keep_in_mind" class="link">Important things to keep in mind</a>
<ul><li><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=3rd+person+camera+system+tutorial&amp;structure=Tutorials#Coordinate_system" class="link">Coordinate system</a>
</li><li><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=3rd+person+camera+system+tutorial&amp;structure=Tutorials#Camera_movement" class="link">Camera movement</a>
</li><li><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=3rd+person+camera+system+tutorial&amp;structure=Tutorials#Tightness" class="link">Tightness</a>
</li></ul></li><li><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=3rd+person+camera+system+tutorial&amp;structure=Tutorials#The_source_code_explained" class="link">The source code, explained</a>
</li><li><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=3rd+person+camera+system+tutorial&amp;structure=Tutorials#Closing_words" class="link">Closing words</a>
</li></ul></ul><!--toc--></div>
<p></p>

<h2 class="showhide_heading" id="The_idea"> The idea</h2>
<p>The idea for this camera system came while I was watching <strong>The Making of Silent Hill 2</strong>,
 where some debug screens appeared and I was able to notice some 
"lines". If you've seen it, you'll understand what I'm talking about.
</p>

<p>Well. The main idea behind this camera system is to have only one 
(usually) camera in the scene at the same moment. As the opposite of 
other 3rd/1st person camera systems, here the camera is "detached" from 
the whole scene (except from the root node which is crucial for it to 
work).
</p>

<p>This philosophy allows us to obtain very nice effects and soft movement, giving a more friendly way to see the scene.
</p>

<p>In general terms, the camera kernel (here called ExtendedCamera) 
consists of two scene nodes, which will act as the camera "handler" and 
the camera target. The handler is supposed to be looking always to the 
target. Moving the target will result in looking around; Moving the 
"handler", in pivoting, rolling... around the target; moving both at the
 same time and amount, panning...
</p>

<p>This is a simple version of the system. Advanced enhancements would 
allow shaking effects, cinematic cameras (crane, rail...) through 
Virtual cameras.
</p>

<p>I'll explain how the three different camera modes included in this demo work
</p>
<h3 class="showhide_heading" id="rd_person_camera_-_Chasing"> 3rd person camera - Chasing</h3>
<p>&nbsp;
<br>We have a main character, who has a main node (the actor), a sight 
node (the point the character is supposed to be looking at), and a chase
 camera node (where we think the best chasing camera should be placed). 
There are other ways to achieve the same effect, but I will use this for
 simplicity.
</p>

<p>What we will do is to use the sight node as the desired position of 
the camera target, and the chase camera node as the desired position of 
the camera itself.
</p>

<p>Further sight nodes will mean the character will me more offseted 
from the center of the screen (for instance, if the character is in 
"investigation" mode in a 3rd person camera game, in the opposite of a 
"walk around" mode). This helps to keep a broad view of the scene, while
 keeping track of the character.
</p>

<h3 class="showhide_heading" id="rd_person_camera_-_Fixed"> 3rd person camera - Fixed</h3>
<p>This kind of camera can be seen in many adventure games like Resident
 Evil, Silent Hill, Alone in the dark... The idea is that the target 
will follow the character sight, but it will remain fixed in a single 
position.
</p>

<p>The way this camera works is similar to the chasing camera.
</p>

<p>Variants of this are crane cameras, rail cameras... used in movie sets.
</p>

<h3 class="showhide_heading" id="st_person_camera"> 1st person camera</h3>
<p>Instead of using the desired chase camera position, we use the 
character position as the desired position for the camera. For this 
mode, cameras with a tightness value of 1 work better (and hiding the 
character model too).
</p>

<p>That's the only difference with the 3rd person cameras described above.
</p>

<p>Look here for a how to that uses the ExampleFrameListener in Samples/Common/include - First person camera <a class="wiki external" target="_blank" href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Creating+a+simple+first-person+camera+system" rel="external nofollow">http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Creating+a+simple+first-person+camera+system</a><img src="test_files/external_link.gif" alt="(external link)" style="border: none" title="(external link)" class="icon" width="15" height="14">
</p>

<h2 class="showhide_heading" id="Important_things_to_keep_in_mind"> Important things to keep in mind</h2>
<h3 class="showhide_heading" id="Coordinate_system"> Coordinate system</h3>
<p>As the camera is independent to any other object in the scene, we will work with world coordinates.
</p>

<h3 class="showhide_heading" id="Camera_movement"> Camera movement</h3>
<p>The camera (and the target) moves in this way. We calculate the 
difference between the camera position and the desired position. As a 
result we get a displacement vector that will be applied to the camera 
so it moves to the desired position.
</p>

<h3 class="showhide_heading" id="Tightness"> Tightness</h3>
<p>As the movement described above is too rigid for us to be 
"user-friendly", we need to find a way to make it smoother. So the 
concept of movement tightness appear. The thightness factor ranges from 
0.0 to 1.0, and determines which proportion of the displacement vector 
will be actually applied.
</p>
<ul><li> Tightness factor of 1.0 results in rigid movement: Each unit the object moves, the camera will move too
</li><li> Tightness factor of 0.0 results in no-movement: The displacement vector will have a length of 0, so no movement is done
</li><li> Thightness factors outside of 0.0 - 1.0 results in undesired behaviors.
</li></ul><p>&nbsp;
</p>
<h2 class="showhide_heading" id="The_source_code_explained"> The source code, explained</h2>
<div class="Layout_box5">You can find this source code ported to <a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=OgreDotNet" title="OgreDotNet" class="wiki">OgreDotNet</a> by Alberts<a href="http://www.ogre3d.org/tikiwiki/tiki-editpage.php?page=User%3AAlberts" title="Create page: User:Alberts" class="wiki wikinew">?</a> <a class="wiki external" target="_blank" href="http://www.ugr.es/local/agsh/ogre/ExtendedCameraSample.zip" rel="external nofollow">here</a><img src="test_files/external_link.gif" alt="(external link)" style="border: none" title="(external link)" class="icon" width="15" height="14"> or attached to this page:  <br>
<a href="http://www.ogre3d.org/tikiwiki/tiki-download_wiki_attachment.php?attId=48&amp;download=y" class="wiki" title="ExtendedCameraSample.zip 5386"><img src="test_files/zip.png">&nbsp;ExtendedCameraSample.zip</a></div>
<p>&nbsp;
</p>
<div class="Layout_box5">You can find this tutorial and source code ported to <a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Python-Ogre" title="Python-Ogre" class="wiki">Python-Ogre</a> by Zyzle<a href="http://www.ogre3d.org/tikiwiki/tiki-editpage.php?page=User%3AZyzle" title="Create page: User:Zyzle" class="wiki wikinew">?</a> <a class="wiki external" target="_blank" href="http://wiki.python-ogre.org/index.php/3rd_Person_Camera_System_Tutorial" rel="external nofollow">here</a><img src="test_files/external_link.gif" alt="(external link)" style="border: none" title="(external link)" class="icon" width="15" height="14"></div>
<p>&nbsp;
<br>First of all, we include a header to use the example framework of OGRE
</p>

<div class="plugincode"><pre class="codelisting" dir="ltr" style="white-space:pre-wrap; white-space:-moz-pre-wrap !important; white-space:-pre-wrap; white-space:-o-pre-wrap; word-wrap:break-word;" id="codebox"><span style="color: #808080; font-style: italic;">/* Camera system tutorial by Kencho */</span>
&nbsp;
<span style="color: #339933;">#include "ExampleApplication.h"</span></pre></div>
<p>&nbsp;
<br>Next, we define a generic Character class. Here, the Character class
 is used to define every object that can be tracked and chased by a 
camera. Of course, in a game or application, this would have many more 
members ;)
</p>
<div class="plugincode"><pre class="codelisting" dir="ltr" style="white-space:pre-wrap; white-space:-moz-pre-wrap !important; white-space:-pre-wrap; white-space:-o-pre-wrap; word-wrap:break-word;" id="codebox1"><span style="color: #666666; font-style: italic;">// Generic Character class</span>
 class Character <span style="color: #009900;">{</span>
 <span style="color: #666666; font-style: italic;">// Attributes ------------------------------------------------------------------------------</span>
     protected<span style="color: #339933;">:</span>
         SceneNode <span style="color: #339933;">*</span>mMainNode<span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Main character node</span>
         SceneNode <span style="color: #339933;">*</span>mSightNode<span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// "Sight" node - The character is supposed to be looking here</span>
         SceneNode <span style="color: #339933;">*</span>mCameraNode<span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Node for the chase camera</span>
         Entity <span style="color: #339933;">*</span>mEntity<span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Character entity</span>
         SceneManager <span style="color: #339933;">*</span>mSceneMgr<span style="color: #339933;">;</span>
     public<span style="color: #339933;">:</span>
 <span style="color: #666666; font-style: italic;">// Methods ---------------------------------------------------------------------------------</span>
     protected<span style="color: #339933;">:</span>
     public<span style="color: #339933;">:</span>
         <span style="color: #666666; font-style: italic;">// Updates the character (movement...)</span>
         virtual <span style="color: #993333;">void</span> update <span style="color: #009900;">(</span>Real elapsedTime<span style="color: #339933;">,</span> OIS<span style="color: #339933;">::</span><span style="color: #202020;">Keyboard</span> <span style="color: #339933;">*</span>input<span style="color: #009900;">)</span> <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
         <span style="color: #666666; font-style: italic;">// The three methods below returns the two camera-related nodes, </span>
         <span style="color: #666666; font-style: italic;">// and the current position of the character (for the 1st person camera)</span>
         SceneNode <span style="color: #339933;">*</span>getSightNode <span style="color: #009900;">(</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
             <span style="color: #b1b100;">return</span> mSightNode<span style="color: #339933;">;</span>
         <span style="color: #009900;">}</span>
         SceneNode <span style="color: #339933;">*</span>getCameraNode <span style="color: #009900;">(</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
             <span style="color: #b1b100;">return</span> mCameraNode<span style="color: #339933;">;</span>
         <span style="color: #009900;">}</span>
         Vector3 getWorldPosition <span style="color: #009900;">(</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
             <span style="color: #b1b100;">return</span> mMainNode<span style="color: #339933;">-&gt;</span>_getDerivedPosition <span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
         <span style="color: #009900;">}</span>
 <span style="color: #009900;">}</span><span style="color: #339933;">;</span></pre></div>
<p>&nbsp;
<br>Next: Our specialization of the Character class for this demo. I 
think a nice floating Ogre head is a cute character for a demo, so we 
define a specialization of the Character class, that will handle, it's 
nodes, model, and a 3D-type movement (turn left/right, advance...)
</p>

<div class="plugincode"><pre class="codelisting" dir="ltr" style="white-space:pre-wrap; white-space:-moz-pre-wrap !important; white-space:-pre-wrap; white-space:-o-pre-wrap; word-wrap:break-word;" id="codebox2"><span style="color: #666666; font-style: italic;">// Specialization of the Character class - Our dear Ogre :D</span>
 class OgreCharacter <span style="color: #339933;">:</span> public Character <span style="color: #009900;">{</span>
 <span style="color: #666666; font-style: italic;">// Attributes ------------------------------------------------------------------------------</span>
     protected<span style="color: #339933;">:</span>
         String mName<span style="color: #339933;">;</span>
     public<span style="color: #339933;">:</span>
 <span style="color: #666666; font-style: italic;">// Methods ---------------------------------------------------------------------------------</span>
     protected<span style="color: #339933;">:</span>
     public<span style="color: #339933;">:</span>
         OgreCharacter <span style="color: #009900;">(</span>String name<span style="color: #339933;">,</span> SceneManager <span style="color: #339933;">*</span>sceneMgr<span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
             <span style="color: #666666; font-style: italic;">// Setup basic member references</span>
             mName <span style="color: #339933;">=</span> name<span style="color: #339933;">;</span>
             mSceneMgr <span style="color: #339933;">=</span> sceneMgr<span style="color: #339933;">;</span>
&nbsp;
             <span style="color: #666666; font-style: italic;">// Setup basic node structure to handle 3rd person cameras</span>
             mMainNode <span style="color: #339933;">=</span> mSceneMgr<span style="color: #339933;">-&gt;</span>getRootSceneNode <span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">-&gt;</span>createChildSceneNode <span style="color: #009900;">(</span>mName<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
             mSightNode <span style="color: #339933;">=</span> mMainNode<span style="color: #339933;">-&gt;</span>createChildSceneNode <span style="color: #009900;">(</span>mName <span style="color: #339933;">+</span> <span style="color: #ff0000;">"_sight"</span><span style="color: #339933;">,</span> Vector3 <span style="color: #009900;">(</span><span style="color: #0000dd;">0</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">100</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
             mCameraNode <span style="color: #339933;">=</span> mMainNode<span style="color: #339933;">-&gt;</span>createChildSceneNode <span style="color: #009900;">(</span>mName <span style="color: #339933;">+</span> <span style="color: #ff0000;">"_camera"</span><span style="color: #339933;">,</span> Vector3 <span style="color: #009900;">(</span><span style="color: #0000dd;">0</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">50</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #0000dd;">100</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
&nbsp;
             <span style="color: #666666; font-style: italic;">// Give this character a shape :)</span>
             mEntity <span style="color: #339933;">=</span> mSceneMgr<span style="color: #339933;">-&gt;</span>createEntity <span style="color: #009900;">(</span>mName<span style="color: #339933;">,</span> <span style="color: #ff0000;">"OgreHead.mesh"</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
             mMainNode<span style="color: #339933;">-&gt;</span>attachObject <span style="color: #009900;">(</span>mEntity<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
         <span style="color: #009900;">}</span>
         ~OgreCharacter <span style="color: #009900;">(</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
             mMainNode<span style="color: #339933;">-&gt;</span>detachAllObjects <span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
             delete mEntity<span style="color: #339933;">;</span>
             mMainNode<span style="color: #339933;">-&gt;</span>removeAndDestroyAllChildren <span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
             mSceneMgr<span style="color: #339933;">-&gt;</span>destroySceneNode <span style="color: #009900;">(</span>mName<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
         <span style="color: #009900;">}</span>
&nbsp;
         <span style="color: #993333;">void</span> update <span style="color: #009900;">(</span>Real elapsedTime<span style="color: #339933;">,</span> OIS<span style="color: #339933;">::</span><span style="color: #202020;">Keyboard</span> <span style="color: #339933;">*</span>input<span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
             <span style="color: #666666; font-style: italic;">// Handle movement</span>
             <span style="color: #b1b100;">if</span> <span style="color: #009900;">(</span>input<span style="color: #339933;">-&gt;</span>isKeyDown <span style="color: #009900;">(</span>OIS<span style="color: #339933;">::</span><span style="color: #202020;">KC_W</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
                 mMainNode<span style="color: #339933;">-&gt;</span>translate <span style="color: #009900;">(</span>mMainNode<span style="color: #339933;">-&gt;</span>getOrientation <span style="color: #009900;">(</span><span style="color: #009900;">)</span> <span style="color: #339933;">*</span> Vector3 <span style="color: #009900;">(</span><span style="color: #0000dd;">0</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">100</span> <span style="color: #339933;">*</span> elapsedTime<span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
             <span style="color: #009900;">}</span>
             <span style="color: #b1b100;">if</span> <span style="color: #009900;">(</span>input<span style="color: #339933;">-&gt;</span>isKeyDown <span style="color: #009900;">(</span>OIS<span style="color: #339933;">::</span><span style="color: #202020;">KC_S</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
                 mMainNode<span style="color: #339933;">-&gt;</span>translate <span style="color: #009900;">(</span>mMainNode<span style="color: #339933;">-&gt;</span>getOrientation <span style="color: #009900;">(</span><span style="color: #009900;">)</span> <span style="color: #339933;">*</span> Vector3 <span style="color: #009900;">(</span><span style="color: #0000dd;">0</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #0000dd;">50</span> <span style="color: #339933;">*</span> elapsedTime<span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
             <span style="color: #009900;">}</span>
             <span style="color: #b1b100;">if</span> <span style="color: #009900;">(</span>input<span style="color: #339933;">-&gt;</span>isKeyDown <span style="color: #009900;">(</span>OIS<span style="color: #339933;">::</span><span style="color: #202020;">KC_A</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
                 mMainNode<span style="color: #339933;">-&gt;</span>yaw <span style="color: #009900;">(</span>Radian <span style="color: #009900;">(</span><span style="color: #0000dd;">2</span> <span style="color: #339933;">*</span> elapsedTime<span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
             <span style="color: #009900;">}</span>
             <span style="color: #b1b100;">if</span> <span style="color: #009900;">(</span>input<span style="color: #339933;">-&gt;</span>isKeyDown <span style="color: #009900;">(</span>OIS<span style="color: #339933;">::</span><span style="color: #202020;">KC_D</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
                 mMainNode<span style="color: #339933;">-&gt;</span>yaw <span style="color: #009900;">(</span>Radian <span style="color: #009900;">(</span><span style="color: #339933;">-</span><span style="color: #0000dd;">2</span> <span style="color: #339933;">*</span> elapsedTime<span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
             <span style="color: #009900;">}</span>
         <span style="color: #009900;">}</span>
&nbsp;
         <span style="color: #666666; font-style: italic;">// Change visibility - Useful for 1st person view ;)</span>
         <span style="color: #993333;">void</span> setVisible <span style="color: #009900;">(</span>bool visible<span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
             mMainNode<span style="color: #339933;">-&gt;</span>setVisible <span style="color: #009900;">(</span>visible<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
         <span style="color: #009900;">}</span>
 <span style="color: #009900;">}</span><span style="color: #339933;">;</span></pre></div>
<p>In order to keep simplicity, I've avoided methods to change the sightness of the character, animating the model...
</p>

<p>Now, the interesting part: The ExtendedCamera class. It follows the 
philosophy I described above. The code is self explanatory, so if you 
have questions about how this works, you can read again the previous 
sections <img alt=":-)" title="smiling" src="test_files/icon_smile.gif">
</p>
<div class="plugincode"><pre class="codelisting" dir="ltr" style="white-space:pre-wrap; white-space:-moz-pre-wrap !important; white-space:-pre-wrap; white-space:-o-pre-wrap; word-wrap:break-word;" id="codebox3"><span style="color: #666666; font-style: italic;">// Our extended camera class</span>
 class ExtendedCamera <span style="color: #009900;">{</span>
 <span style="color: #666666; font-style: italic;">// Attributes ------------------------------------------------------------------------------</span>
     protected<span style="color: #339933;">:</span>
         SceneNode <span style="color: #339933;">*</span>mTargetNode<span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// The camera target</span>
         SceneNode <span style="color: #339933;">*</span>mCameraNode<span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// The camera itself</span>
         Camera <span style="color: #339933;">*</span>mCamera<span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Ogre camera</span>
&nbsp;
         SceneManager <span style="color: #339933;">*</span>mSceneMgr<span style="color: #339933;">;</span>
         String mName<span style="color: #339933;">;</span>
&nbsp;
         bool mOwnCamera<span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// To know if the ogre camera binded has been created outside or inside of this class</span>
&nbsp;
         Real mTightness<span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Determines the movement of the camera - 1 means tight movement, while 0 means no movement</span>
     public<span style="color: #339933;">:</span>
 <span style="color: #666666; font-style: italic;">// Methods ---------------------------------------------------------------------------------</span>
     protected<span style="color: #339933;">:</span>
     public<span style="color: #339933;">:</span>
         ExtendedCamera <span style="color: #009900;">(</span>String name<span style="color: #339933;">,</span> SceneManager <span style="color: #339933;">*</span>sceneMgr<span style="color: #339933;">,</span> Camera <span style="color: #339933;">*</span>camera <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
             <span style="color: #666666; font-style: italic;">// Basic member references setup</span>
             mName <span style="color: #339933;">=</span> name<span style="color: #339933;">;</span>
             mSceneMgr <span style="color: #339933;">=</span> sceneMgr<span style="color: #339933;">;</span>
&nbsp;
             <span style="color: #666666; font-style: italic;">// Create the camera's node structure</span>
             mCameraNode <span style="color: #339933;">=</span> mSceneMgr<span style="color: #339933;">-&gt;</span>getRootSceneNode <span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">-&gt;</span>createChildSceneNode <span style="color: #009900;">(</span>mName<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
             mTargetNode <span style="color: #339933;">=</span> mSceneMgr<span style="color: #339933;">-&gt;</span>getRootSceneNode <span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">-&gt;</span>createChildSceneNode <span style="color: #009900;">(</span>mName <span style="color: #339933;">+</span> <span style="color: #ff0000;">"_target"</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
             mCameraNode<span style="color: #339933;">-&gt;</span>setAutoTracking <span style="color: #009900;">(</span><span style="color: #000000; font-weight: bold;">true</span><span style="color: #339933;">,</span> mTargetNode<span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// The camera will always look at the camera target</span>
             mCameraNode<span style="color: #339933;">-&gt;</span>setFixedYawAxis <span style="color: #009900;">(</span><span style="color: #000000; font-weight: bold;">true</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Needed because of auto tracking</span>
&nbsp;
             <span style="color: #666666; font-style: italic;">// Create our camera if it wasn't passed as a parameter</span>
             <span style="color: #b1b100;">if</span> <span style="color: #009900;">(</span>camera <span style="color: #339933;">==</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
                 mCamera <span style="color: #339933;">=</span> mSceneMgr<span style="color: #339933;">-&gt;</span>createCamera <span style="color: #009900;">(</span>mName<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
                 mOwnCamera <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">true</span><span style="color: #339933;">;</span>
             <span style="color: #009900;">}</span>
             <span style="color: #b1b100;">else</span> <span style="color: #009900;">{</span>
                 mCamera <span style="color: #339933;">=</span> camera<span style="color: #339933;">;</span>
                                 <span style="color: #666666; font-style: italic;">// just to make sure that mCamera is set to 'origin' (same position as the mCameraNode)</span>
                                 mCamera<span style="color: #339933;">-&gt;</span>setPosition<span style="color: #009900;">(</span><span style="color:#800080;">0.0</span><span style="color: #339933;">,</span><span style="color:#800080;">0.0</span><span style="color: #339933;">,</span><span style="color:#800080;">0.0</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
                 mOwnCamera <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">false</span><span style="color: #339933;">;</span>
             <span style="color: #009900;">}</span>
             <span style="color: #666666; font-style: italic;">// ... and attach the Ogre camera to the camera node</span>
             mCameraNode<span style="color: #339933;">-&gt;</span>attachObject <span style="color: #009900;">(</span>mCamera<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
&nbsp;
             <span style="color: #666666; font-style: italic;">// Default tightness</span>
             mTightness <span style="color: #339933;">=</span> <span style="color:#800080;">0.01f</span><span style="color: #339933;">;</span>
         <span style="color: #009900;">}</span>
         ~ExtendedCamera <span style="color: #009900;">(</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
             mCameraNode<span style="color: #339933;">-&gt;</span>detachAllObjects <span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
             <span style="color: #b1b100;">if</span> <span style="color: #009900;">(</span>mOwnCamera<span style="color: #009900;">)</span>
                 delete mCamera<span style="color: #339933;">;</span>
             mSceneMgr<span style="color: #339933;">-&gt;</span>destroySceneNode <span style="color: #009900;">(</span>mName<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
             mSceneMgr<span style="color: #339933;">-&gt;</span>destroySceneNode <span style="color: #009900;">(</span>mName <span style="color: #339933;">+</span> <span style="color: #ff0000;">"_target"</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
         <span style="color: #009900;">}</span>
&nbsp;
         <span style="color: #993333;">void</span> setTightness <span style="color: #009900;">(</span>Real tightness<span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
             mTightness <span style="color: #339933;">=</span> tightness<span style="color: #339933;">;</span>
         <span style="color: #009900;">}</span>
&nbsp;
         Real getTightness <span style="color: #009900;">(</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
             <span style="color: #b1b100;">return</span> mTightness<span style="color: #339933;">;</span>
         <span style="color: #009900;">}</span>
&nbsp;
         Vector3 getCameraPosition <span style="color: #009900;">(</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
             <span style="color: #b1b100;">return</span> mCameraNode<span style="color: #339933;">-&gt;</span>getPosition <span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
         <span style="color: #009900;">}</span>
&nbsp;
         <span style="color: #993333;">void</span> instantUpdate <span style="color: #009900;">(</span>Vector3 cameraPosition<span style="color: #339933;">,</span> Vector3 targetPosition<span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
             mCameraNode<span style="color: #339933;">-&gt;</span>setPosition <span style="color: #009900;">(</span>cameraPosition<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
             mTargetNode<span style="color: #339933;">-&gt;</span>setPosition <span style="color: #009900;">(</span>targetPosition<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
         <span style="color: #009900;">}</span>
&nbsp;
         <span style="color: #993333;">void</span> update <span style="color: #009900;">(</span>Real elapsedTime<span style="color: #339933;">,</span> Vector3 cameraPosition<span style="color: #339933;">,</span> Vector3 targetPosition<span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
             <span style="color: #666666; font-style: italic;">// Handle movement</span>
             Vector3 displacement<span style="color: #339933;">;</span>
&nbsp;
             displacement <span style="color: #339933;">=</span> <span style="color: #009900;">(</span>cameraPosition <span style="color: #339933;">-</span> mCameraNode<span style="color: #339933;">-&gt;</span>getPosition <span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span> <span style="color: #339933;">*</span> mTightness<span style="color: #339933;">;</span>
             mCameraNode<span style="color: #339933;">-&gt;</span>translate <span style="color: #009900;">(</span>displacement<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
&nbsp;
             displacement <span style="color: #339933;">=</span> <span style="color: #009900;">(</span>targetPosition <span style="color: #339933;">-</span> mTargetNode<span style="color: #339933;">-&gt;</span>getPosition <span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span> <span style="color: #339933;">*</span> mTightness<span style="color: #339933;">;</span>
             mTargetNode<span style="color: #339933;">-&gt;</span>translate <span style="color: #009900;">(</span>displacement<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
         <span style="color: #009900;">}</span>
 <span style="color: #009900;">}</span><span style="color: #339933;">;</span></pre></div>
<p>A sample frame listener that will handle the update of the character 
and the camera, and camera mode changes. Again, self explanatory code 
and philosophy explained above.
</p>
<div class="plugincode"><pre class="codelisting" dir="ltr" style="white-space:pre-wrap; white-space:-moz-pre-wrap !important; white-space:-pre-wrap; white-space:-o-pre-wrap; word-wrap:break-word;" id="codebox4">class SampleListener <span style="color: #339933;">:</span> public ExampleFrameListener
 <span style="color: #009900;">{</span>
 protected<span style="color: #339933;">:</span>
     <span style="color: #666666; font-style: italic;">// References to the main character and the camera</span>
     Character <span style="color: #339933;">*</span>mChar<span style="color: #339933;">;</span>
     ExtendedCamera <span style="color: #339933;">*</span>mExCamera<span style="color: #339933;">;</span>
&nbsp;
     <span style="color: #666666; font-style: italic;">// Camera mode - Now supports 1st person, 3rd person (chasing) and 3rd person (fixed)</span>
     <span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span> mMode<span style="color: #339933;">;</span>
&nbsp;
 public<span style="color: #339933;">:</span>
     SampleListener<span style="color: #009900;">(</span>RenderWindow<span style="color: #339933;">*</span> win<span style="color: #339933;">,</span> Camera<span style="color: #339933;">*</span> cam<span style="color: #009900;">)</span>
     <span style="color: #339933;">:</span> ExampleFrameListener<span style="color: #009900;">(</span>win<span style="color: #339933;">,</span> cam<span style="color: #009900;">)</span>
     <span style="color: #009900;">{</span>
         mChar <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
         mExCamera <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
         mMode <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
     <span style="color: #009900;">}</span>
&nbsp;
     <span style="color: #993333;">void</span> setCharacter <span style="color: #009900;">(</span>Character <span style="color: #339933;">*</span>character<span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
         mChar <span style="color: #339933;">=</span> character<span style="color: #339933;">;</span>
     <span style="color: #009900;">}</span>
&nbsp;
     <span style="color: #993333;">void</span> setExtendedCamera <span style="color: #009900;">(</span>ExtendedCamera <span style="color: #339933;">*</span>cam<span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
         mExCamera <span style="color: #339933;">=</span> cam<span style="color: #339933;">;</span>
     <span style="color: #009900;">}</span>
&nbsp;
     bool frameStarted<span style="color: #009900;">(</span><span style="color: #993333;">const</span> FrameEvent<span style="color: #339933;">&amp;</span> evt<span style="color: #009900;">)</span>
     <span style="color: #009900;">{</span>
         mKeyboard<span style="color: #339933;">-&gt;</span>capture<span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
&nbsp;
         <span style="color: #b1b100;">if</span> <span style="color: #009900;">(</span>mChar<span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
             mChar<span style="color: #339933;">-&gt;</span>update <span style="color: #009900;">(</span>evt.<span style="color: #202020;">timeSinceLastFrame</span><span style="color: #339933;">,</span> mKeyboard<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
&nbsp;
             <span style="color: #b1b100;">if</span> <span style="color: #009900;">(</span>mExCamera<span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
                 <span style="color: #b1b100;">switch</span> <span style="color: #009900;">(</span>mMode<span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
                     <span style="color: #b1b100;">case</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">:</span> <span style="color: #666666; font-style: italic;">// 3rd person chase</span>
                         mExCamera<span style="color: #339933;">-&gt;</span>update <span style="color: #009900;">(</span>evt.<span style="color: #202020;">timeSinceLastFrame</span><span style="color: #339933;">,</span> 
                                             mChar<span style="color: #339933;">-&gt;</span>getCameraNode <span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">-&gt;</span>getWorldPosition <span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">,</span> 
                                             mChar<span style="color: #339933;">-&gt;</span>getSightNode <span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">-&gt;</span>getWorldPosition <span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
                         <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
                     <span style="color: #b1b100;">case</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">:</span> <span style="color: #666666; font-style: italic;">// 3rd person fixed</span>
                         mExCamera<span style="color: #339933;">-&gt;</span>update <span style="color: #009900;">(</span>evt.<span style="color: #202020;">timeSinceLastFrame</span><span style="color: #339933;">,</span> 
                                             Vector3 <span style="color: #009900;">(</span><span style="color: #0000dd;">0</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">200</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">)</span><span style="color: #339933;">,</span> 
                                             mChar<span style="color: #339933;">-&gt;</span>getSightNode <span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">-&gt;</span>getWorldPosition <span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
                         <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
                     <span style="color: #b1b100;">case</span> <span style="color: #0000dd;">2</span><span style="color: #339933;">:</span> <span style="color: #666666; font-style: italic;">// 1st person</span>
                         mExCamera<span style="color: #339933;">-&gt;</span>update <span style="color: #009900;">(</span>evt.<span style="color: #202020;">timeSinceLastFrame</span><span style="color: #339933;">,</span> 
                                             mChar<span style="color: #339933;">-&gt;</span>getWorldPosition <span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">,</span> 
                                             mChar<span style="color: #339933;">-&gt;</span>getSightNode <span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">-&gt;</span>getWorldPosition <span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
                         <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
                 <span style="color: #009900;">}</span>
             <span style="color: #009900;">}</span>
         <span style="color: #009900;">}</span>
&nbsp;
         <span style="color: #666666; font-style: italic;">// 3rd Person - Chase Camera</span>
         <span style="color: #b1b100;">if</span> <span style="color: #009900;">(</span>mKeyboard<span style="color: #339933;">-&gt;</span>isKeyDown <span style="color: #009900;">(</span>OIS<span style="color: #339933;">::</span><span style="color: #202020;">KC_F1</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
             mMode <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
             <span style="color: #b1b100;">if</span> <span style="color: #009900;">(</span>mChar<span style="color: #009900;">)</span>
                 static_cast<span style="color: #339933;">&lt;</span>OgreCharacter <span style="color: #339933;">*&gt;</span><span style="color: #009900;">(</span>mChar<span style="color: #009900;">)</span><span style="color: #339933;">-&gt;</span>setVisible <span style="color: #009900;">(</span><span style="color: #000000; font-weight: bold;">true</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
             <span style="color: #b1b100;">if</span> <span style="color: #009900;">(</span>mExCamera<span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
                 <span style="color: #b1b100;">if</span> <span style="color: #009900;">(</span>mChar<span style="color: #009900;">)</span>
                     mExCamera<span style="color: #339933;">-&gt;</span>instantUpdate <span style="color: #009900;">(</span>mChar<span style="color: #339933;">-&gt;</span>getCameraNode <span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">-&gt;</span>getWorldPosition <span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">,</span> mChar<span style="color: #339933;">-&gt;</span>getSightNode <span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">-&gt;</span>getWorldPosition <span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
                 mExCamera<span style="color: #339933;">-&gt;</span>setTightness <span style="color: #009900;">(</span><span style="color:#800080;">0.01f</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
             <span style="color: #009900;">}</span>
          <span style="color: #009900;">}</span>
         <span style="color: #666666; font-style: italic;">// 3rd Person - Fixed Camera</span>
         <span style="color: #b1b100;">if</span> <span style="color: #009900;">(</span>mKeyboard<span style="color: #339933;">-&gt;</span>isKeyDown <span style="color: #009900;">(</span>OIS<span style="color: #339933;">::</span><span style="color: #202020;">KC_F2</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
             mMode <span style="color: #339933;">=</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">;</span>
             <span style="color: #b1b100;">if</span> <span style="color: #009900;">(</span>mChar<span style="color: #009900;">)</span>
                 static_cast<span style="color: #339933;">&lt;</span>OgreCharacter <span style="color: #339933;">*&gt;</span><span style="color: #009900;">(</span>mChar<span style="color: #009900;">)</span><span style="color: #339933;">-&gt;</span>setVisible <span style="color: #009900;">(</span><span style="color: #000000; font-weight: bold;">true</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
             <span style="color: #b1b100;">if</span> <span style="color: #009900;">(</span>mExCamera<span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
                 <span style="color: #b1b100;">if</span> <span style="color: #009900;">(</span>mChar<span style="color: #009900;">)</span>
                     mExCamera<span style="color: #339933;">-&gt;</span>instantUpdate <span style="color: #009900;">(</span>Vector3 <span style="color: #009900;">(</span><span style="color: #0000dd;">0</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">200</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">)</span><span style="color: #339933;">,</span> mChar<span style="color: #339933;">-&gt;</span>getSightNode <span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">-&gt;</span>getWorldPosition <span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
                 mExCamera<span style="color: #339933;">-&gt;</span>setTightness <span style="color: #009900;">(</span><span style="color:#800080;">0.01f</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
             <span style="color: #009900;">}</span>
         <span style="color: #009900;">}</span>
         <span style="color: #666666; font-style: italic;">// 1st Person</span>
         <span style="color: #b1b100;">if</span> <span style="color: #009900;">(</span>mKeyboard<span style="color: #339933;">-&gt;</span>isKeyDown <span style="color: #009900;">(</span>OIS<span style="color: #339933;">::</span><span style="color: #202020;">KC_F3</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span>  <span style="color: #009900;">{</span>
             mMode <span style="color: #339933;">=</span> <span style="color: #0000dd;">2</span><span style="color: #339933;">;</span>
             <span style="color: #b1b100;">if</span> <span style="color: #009900;">(</span>mChar<span style="color: #009900;">)</span>
                 static_cast<span style="color: #339933;">&lt;</span>OgreCharacter <span style="color: #339933;">*&gt;</span><span style="color: #009900;">(</span>mChar<span style="color: #009900;">)</span><span style="color: #339933;">-&gt;</span>setVisible <span style="color: #009900;">(</span><span style="color: #000000; font-weight: bold;">false</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
             <span style="color: #b1b100;">if</span> <span style="color: #009900;">(</span>mExCamera<span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
                 <span style="color: #b1b100;">if</span> <span style="color: #009900;">(</span>mChar<span style="color: #009900;">)</span>
                     mExCamera<span style="color: #339933;">-&gt;</span>instantUpdate <span style="color: #009900;">(</span>mChar<span style="color: #339933;">-&gt;</span>getWorldPosition <span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">,</span> mChar<span style="color: #339933;">-&gt;</span>getSightNode <span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">-&gt;</span>getWorldPosition <span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
                 mExCamera<span style="color: #339933;">-&gt;</span>setTightness <span style="color: #009900;">(</span><span style="color:#800080;">1.0f</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
             <span style="color: #009900;">}</span>
         <span style="color: #009900;">}</span>
&nbsp;
         <span style="color: #666666; font-style: italic;">// Exit if we press Esc</span>
         <span style="color: #b1b100;">if</span><span style="color: #009900;">(</span>mKeyboard<span style="color: #339933;">-&gt;</span>isKeyDown <span style="color: #009900;">(</span>OIS<span style="color: #339933;">::</span><span style="color: #202020;">KC_ESCAPE</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span>
             <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">false</span><span style="color: #339933;">;</span>
&nbsp;
         <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">true</span><span style="color: #339933;">;</span>
     <span style="color: #009900;">}</span>
 <span style="color: #009900;">}</span><span style="color: #339933;">;</span></pre></div>
<p>A sample application. If you have doubts about this, try reading other sections of the wiki <img alt=":-)" title="smiling" src="test_files/icon_smile.gif">
</p>
<div class="plugincode"><pre class="codelisting" dir="ltr" style="white-space:pre-wrap; white-space:-moz-pre-wrap !important; white-space:-pre-wrap; white-space:-o-pre-wrap; word-wrap:break-word;" id="codebox5">class SampleApplication <span style="color: #339933;">:</span> public ExampleApplication
 <span style="color: #009900;">{</span>
 protected<span style="color: #339933;">:</span>
 public<span style="color: #339933;">:</span>
     SampleApplication<span style="color: #009900;">(</span><span style="color: #009900;">)</span>
     <span style="color: #009900;">{</span>
     <span style="color: #009900;">}</span>
     ~SampleApplication<span style="color: #009900;">(</span><span style="color: #009900;">)</span>
     <span style="color: #009900;">{</span>
     <span style="color: #009900;">}</span>
&nbsp;
 protected<span style="color: #339933;">:</span>
     <span style="color: #666666; font-style: italic;">// Just override the mandatory create scene method</span>
     <span style="color: #993333;">void</span> createScene<span style="color: #009900;">(</span><span style="color: #993333;">void</span><span style="color: #009900;">)</span>
     <span style="color: #009900;">{</span>
         <span style="color: #666666; font-style: italic;">// Set ambient light</span>
         mSceneMgr<span style="color: #339933;">-&gt;</span>setAmbientLight<span style="color: #009900;">(</span>ColourValue<span style="color: #009900;">(</span><span style="color:#800080;">0.2</span><span style="color: #339933;">,</span> <span style="color:#800080;">0.2</span><span style="color: #339933;">,</span> <span style="color:#800080;">0.2</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
&nbsp;
         <span style="color: #666666; font-style: italic;">// LIGHTS!!</span>
         <span style="color: #666666; font-style: italic;">// Create a point light</span>
         Light<span style="color: #339933;">*</span> l <span style="color: #339933;">=</span> mSceneMgr<span style="color: #339933;">-&gt;</span>createLight<span style="color: #009900;">(</span><span style="color: #ff0000;">"MainLight"</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
         <span style="color: #666666; font-style: italic;">// Accept default settings: point light, white diffuse, just set position</span>
         <span style="color: #666666; font-style: italic;">// NB I could attach the light to a SceneNode if I wanted it to move automatically with</span>
         <span style="color: #666666; font-style: italic;">//  other objects, but I don't</span>
         l<span style="color: #339933;">-&gt;</span>setType<span style="color: #009900;">(</span>Light<span style="color: #339933;">::</span><span style="color: #202020;">LT_DIRECTIONAL</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
         l<span style="color: #339933;">-&gt;</span>setDirection<span style="color: #009900;">(</span><span style="color: #339933;">-</span><span style="color:#800080;">0.5</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color:#800080;">0.5</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
&nbsp;
         <span style="color: #666666; font-style: italic;">// CAMERA!!</span>
         mCamera<span style="color: #339933;">-&gt;</span>setPosition <span style="color: #009900;">(</span><span style="color: #0000dd;">0</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>    <span style="color: #666666; font-style: italic;">// Required or else the camera will have an offset</span>
&nbsp;
         <span style="color: #666666; font-style: italic;">// ACTION!!!</span>
         <span style="color: #666666; font-style: italic;">// Fill the scene with some razors</span>
         SceneNode <span style="color: #339933;">*</span>razorNode<span style="color: #339933;">;</span>
         Entity <span style="color: #339933;">*</span>razorEntity<span style="color: #339933;">;</span>
         <span style="color: #b1b100;">for</span> <span style="color: #009900;">(</span><span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span> i <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> <span style="color: #0000dd;">30</span><span style="color: #339933;">;</span> <span style="color: #339933;">++</span>i<span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
             razorNode <span style="color: #339933;">=</span> mSceneMgr<span style="color: #339933;">-&gt;</span>getRootSceneNode <span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">-&gt;</span>createChildSceneNode <span style="color: #009900;">(</span>StringConverter<span style="color: #339933;">::</span><span style="color: #202020;">toString</span> <span style="color: #009900;">(</span>i<span style="color: #009900;">)</span><span style="color: #339933;">,</span> Vector3 <span style="color: #009900;">(</span>Math<span style="color: #339933;">::</span><span style="color: #202020;">RangeRandom</span> <span style="color: #009900;">(</span><span style="color: #339933;">-</span><span style="color: #0000dd;">1000</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">1000</span><span style="color: #009900;">)</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">,</span> Math<span style="color: #339933;">::</span><span style="color: #202020;">RangeRandom</span> <span style="color: #009900;">(</span><span style="color: #339933;">-</span><span style="color: #0000dd;">1000</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">1000</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
             razorEntity <span style="color: #339933;">=</span> mSceneMgr<span style="color: #339933;">-&gt;</span>createEntity <span style="color: #009900;">(</span>StringConverter<span style="color: #339933;">::</span><span style="color: #202020;">toString</span> <span style="color: #009900;">(</span>i<span style="color: #009900;">)</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">"razor.mesh"</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
             razorNode<span style="color: #339933;">-&gt;</span>attachObject <span style="color: #009900;">(</span>razorEntity<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
         <span style="color: #009900;">}</span>
&nbsp;
         <span style="color: #666666; font-style: italic;">// Main character</span>
         OgreCharacter <span style="color: #339933;">*</span>ogre <span style="color: #339933;">=</span> new OgreCharacter <span style="color: #009900;">(</span><span style="color: #ff0000;">"Ogre 1"</span><span style="color: #339933;">,</span> mSceneMgr<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
         ExtendedCamera <span style="color: #339933;">*</span>exCamera <span style="color: #339933;">=</span> new ExtendedCamera <span style="color: #009900;">(</span><span style="color: #ff0000;">"Extended Camera"</span><span style="color: #339933;">,</span> mSceneMgr<span style="color: #339933;">,</span> mCamera<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
&nbsp;
         <span style="color: #666666; font-style: italic;">// Frame listener to manage both character and camera updating and different camera modes</span>
         <span style="color: #666666; font-style: italic;">// Need to create it here as we want to change some parameters here, thus avoiding defining </span>
         <span style="color: #666666; font-style: italic;">// ogre and exCamera as member variables</span>
         mFrameListener <span style="color: #339933;">=</span> new SampleListener <span style="color: #009900;">(</span>mWindow<span style="color: #339933;">,</span> mCamera<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
         static_cast<span style="color: #339933;">&lt;</span>SampleListener <span style="color: #339933;">*&gt;</span><span style="color: #009900;">(</span>mFrameListener<span style="color: #009900;">)</span><span style="color: #339933;">-&gt;</span>setCharacter <span style="color: #009900;">(</span>ogre<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
         static_cast<span style="color: #339933;">&lt;</span>SampleListener <span style="color: #339933;">*&gt;</span><span style="color: #009900;">(</span>mFrameListener<span style="color: #009900;">)</span><span style="color: #339933;">-&gt;</span>setExtendedCamera <span style="color: #009900;">(</span>exCamera<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
     <span style="color: #009900;">}</span>
     <span style="color: #993333;">void</span> destroyScene<span style="color: #009900;">(</span><span style="color: #993333;">void</span><span style="color: #009900;">)</span>
     <span style="color: #009900;">{</span>
     <span style="color: #009900;">}</span>
     <span style="color: #993333;">void</span> createFrameListener<span style="color: #009900;">(</span><span style="color: #993333;">void</span><span style="color: #009900;">)</span>
     <span style="color: #009900;">{</span>
         <span style="color: #666666; font-style: italic;">// This is where we instantiate our own frame listener</span>
 <span style="color: #666666; font-style: italic;">//        mFrameListener= new SampleListener(mWindow, mCamera);</span>
         mRoot<span style="color: #339933;">-&gt;</span>addFrameListener<span style="color: #009900;">(</span>mFrameListener<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
     <span style="color: #009900;">}</span>
 <span style="color: #009900;">}</span><span style="color: #339933;">;</span></pre></div>
<p>Note that in the method createFrameListener(), the frame listener 
won't be constructed as we did in the createScene() method, so there 
won't be two frame listeners. This is important as the second (and used)
 one, if we would create it in createFrameListener(), wouldn't be 
configured, and thus would crash the application.
</p>

<p>To make it able to run
</p>

<div class="plugincode"><pre class="codelisting" dir="ltr" style="white-space:pre-wrap; white-space:-moz-pre-wrap !important; white-space:-pre-wrap; white-space:-o-pre-wrap; word-wrap:break-word;" id="codebox6"><span style="color: #339933;">#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32</span>
 <span style="color: #339933;">#define WIN32_LEAN_AND_MEAN</span>
 <span style="color: #339933;">#include "windows.h"</span>
&nbsp;
 INT WINAPI WinMain<span style="color: #009900;">(</span> HINSTANCE hInst<span style="color: #339933;">,</span> HINSTANCE<span style="color: #339933;">,</span> LPSTR strCmdLine<span style="color: #339933;">,</span> INT <span style="color: #009900;">)</span>
 <span style="color: #339933;">#else</span>
 <span style="color: #993333;">int</span> main<span style="color: #009900;">(</span><span style="color: #993333;">int</span> argc<span style="color: #339933;">,</span> <span style="color: #993333;">char</span> <span style="color: #339933;">**</span>argv<span style="color: #009900;">)</span>
 <span style="color: #339933;">#endif</span>
 <span style="color: #009900;">{</span>
    <span style="color: #666666; font-style: italic;">// Create application object</span>
    SampleApplication app<span style="color: #339933;">;</span>
&nbsp;
    try <span style="color: #009900;">{</span>
        app.<span style="color: #202020;">go</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">}</span> catch<span style="color: #009900;">(</span> Exception<span style="color: #339933;">&amp;</span> e <span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
 <span style="color: #339933;">#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 </span>
        MessageBox<span style="color: #009900;">(</span> NULL<span style="color: #339933;">,</span> e.<span style="color: #202020;">getFullDescription</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span>.<span style="color: #202020;">c_str</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">"An exception has occured!"</span><span style="color: #339933;">,</span> MB_OK <span style="color: #339933;">|</span>      MB_ICONERROR <span style="color: #339933;">|</span> MB_TASKMODAL<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
 <span style="color: #339933;">#else</span>
        fprintf<span style="color: #009900;">(</span>stderr<span style="color: #339933;">,</span> <span style="color: #ff0000;">"An exception has occured: %s<span style="color: #000099; font-weight: bold;">\n</span>"</span><span style="color: #339933;">,</span>
                e.<span style="color: #202020;">getFullDescription</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span>.<span style="color: #202020;">c_str</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
 <span style="color: #339933;">#endif</span>
    <span style="color: #009900;">}</span>
&nbsp;
    <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">}</span></pre></div>
<p>&nbsp;
</p>
<h2 class="showhide_heading" id="Closing_words"> Closing words</h2>
<p>Hope you find this useful. I'll be updating this later, fixing some explanations and methods. Thanks for reading.
<br><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=User%3AKencho" title="User:Kencho" class="wiki">Kencho</a>
</p>
<hr>
<p>Alias: <a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=3rd_person_camera_system_tutorial" title="3rd_person_camera_system_tutorial" class="wiki alias">3rd_person_camera_system_tutorial</a>
</p>

	
	
	<hr class="hrwikibottom"> 

	
	</div> 




	<p class="editdate">
			Contributors to this page: <a class="link titletips" title="User information - Click for more info|&lt;img src='img/icons/star_yellow.gif' height='11' width='11' alt='1192 points' /&gt;&amp;nbsp;1192&lt;br /&gt;Last seen on Thu 27 of June, 2013 [21:24 UTC]&lt;br /&gt;" href="http://www.ogre3d.org/tikiwiki/tiki-user_information.php?userId=572">drwbns</a><img src="test_files/star_yellow.gif" alt="1192 points" width="11" height="11">&nbsp;
						,
				<a class="link titletips" title="User information - Click for more info|&lt;table&gt;&lt;tr&gt;&lt;td&gt;&lt;img border='0' src='temp/public//avatar_spacegaier.jpg'  alt='spacegaier' /&gt;&lt;/td&gt;&lt;td&gt;&lt;img src='img/icons/star_red.gif' height='11' width='11' alt='6073 points' /&gt;&amp;nbsp;6073&lt;br /&gt;&lt;img src='img/flags/Germany.gif' /&gt; Germany&lt;br /&gt;Last seen on Sat 31 of May, 2014 [09:51 UTC]&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;" href="http://www.ogre3d.org/tikiwiki/tiki-user_information.php?userId=10"><i class="highlightgroup"><b>Spacegaier</b></i></a><img src="test_files/star_red.gif" alt="6073 points" width="11" height="11">&nbsp;
						,
				<span class="link">JustBoo</span>
			 
			and
				<a class="link titletips" title="User information - Click for more info|&lt;table&gt;&lt;tr&gt;&lt;td&gt;&lt;img border='0' src='temp/public//avatar_jacmoe.jpg'  alt='jacmoe' /&gt;&lt;/td&gt;&lt;td&gt;Jacob Moen&lt;br /&gt;&lt;img src='img/icons/star_purple.gif' height='11' width='11' alt='180265 points' /&gt;&amp;nbsp;180265&lt;br /&gt;&lt;img src='img/flags/Denmark.gif' /&gt; Denmark&lt;br /&gt;Last seen on Mon 17 of Sep., 2012 [16:36 UTC]&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;" href="http://www.ogre3d.org/tikiwiki/tiki-user_information.php?userId=2"><i class="highlightgroup"><b>jacmoe</b></i></a><img src="test_files/star_purple.gif" alt="180265 points" width="11" height="11">&nbsp;
	.
	<br>
	Page last modified on Monday 17 of December, 2012 17:57:06 UTC by <a class="link titletips" title="User information - Click for more info|&lt;img src='img/icons/star_yellow.gif' height='11' width='11' alt='1192 points' /&gt;&amp;nbsp;1192&lt;br /&gt;Last seen on Thu 27 of June, 2013 [21:24 UTC]&lt;br /&gt;" href="http://www.ogre3d.org/tikiwiki/tiki-user_information.php?userId=572">drwbns</a><img src="test_files/star_yellow.gif" alt="1192 points" width="11" height="11">&nbsp;. 
	
			</p><hr>
		The content on this page is licensed under the terms of the <a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Creative+Commons+Attribution-ShareAlike+License&amp;copyrightpage=3rd%20person%20camera%20system%20tutorial">Creative Commons Attribution-ShareAlike License</a>.
		<br>As an exception, any source code contributed within the content is released into the <a href="http://www.ogre3d.org/tikiwiki/tiki-index?page=Public%20Domain%20Unlicense">Public Domain</a>.
	<hr>

	<p></p>



			
<div class="clearfix" id="page-bar"><span class="button"><a href="http://www.ogre3d.org/tikiwiki/tiki-pagehistory.php?page=3rd+person+camera+system+tutorial&amp;source=0">Source</a></span><span class="button"><a href="http://www.ogre3d.org/tikiwiki/tiki-pagehistory.php?page=3rd+person+camera+system+tutorial">History</a></span>
				<noscript>
	&lt;span class="button highlight"&gt;&lt;a  href="/tikiwiki/tiki-index.php?comzone=show#comments" &gt;1 comment&lt;/a&gt;&lt;/span&gt;
</noscript>
	<span class="button highlight"><a onclick="javascript:flip('comzone059fdc27c203b6df159bc0ef6a68ae79');flip('comzone059fdc27c203b6df159bc0ef6a68ae79_close','inline');return false;" href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=3rd+person+camera+system+tutorial#comments">1 comment<span id="comzone059fdc27c203b6df159bc0ef6a68ae79_close" style="display:none;"> (Hide)</span></a></span>
<span class="button highlight"><a onclick="javascript:flip('attzone059fdc27c203b6df159bc0ef6a68ae79');flip('attzone059fdc27c203b6df159bc0ef6a68ae79_close','inline');return false;" href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=3rd+person+camera+system+tutorial&amp;structure=Tutorials#attachments">1 File Attached<span id="attzone059fdc27c203b6df159bc0ef6a68ae79_close" style="display:none;"> (Hide)</span></a></span></div><a name="attachments"></a>

<a name="attachments"></a>

	<div id="attzone059fdc27c203b6df159bc0ef6a68ae79" style="display:none;">

	

			<table class="normal">
			<caption> List of attached files </caption>
			<tbody><tr>
				<th>&nbsp;</th>
				<th>
					<a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=3rd%20person%20camera%20system%20tutorial&amp;offset=&amp;sort_mode=attId_desc&amp;atts_show=y#attachments">ID</a>
				</th>
				<th>
					<a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=3rd%20person%20camera%20system%20tutorial&amp;offset=&amp;sort_mode=filename_desc&amp;atts_show=y#attachments">Name</a>
				</th>
				<th>&nbsp;</th>
				<th>
					<a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=3rd%20person%20camera%20system%20tutorial&amp;offset=&amp;sort_mode=comment_desc&amp;atts_show=y#attachments">desc</a>
				</th>
				<th>
					<a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=3rd%20person%20camera%20system%20tutorial&amp;offset=&amp;sort_mode=created_asc&amp;atts_show=y#attachments">uploaded</a>
				</th>
				<th>
					<a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=3rd%20person%20camera%20system%20tutorial&amp;offset=&amp;sort_mode=size_desc&amp;atts_show=y#attachments">Size</a>
				</th>
				<th>
					<a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=3rd%20person%20camera%20system%20tutorial&amp;offset=&amp;sort_mode=hits_desc&amp;atts_show=y#attachments">Downloads</a>
				</th>
			</tr>
			
							<tr class="odd">
					<td>1</td>
					<td>48</td>
					<td>
						<img src="test_files/zip.png" alt="zip" style="border: none" title="zip" width="16" height="16">
						<a class="tablename" href="http://www.ogre3d.org/tikiwiki/tiki-download_wiki_attachment.php?attId=48&amp;page=3rd%20person%20camera%20system%20tutorial&amp;download=y">ExtendedCameraSample.zip</a>
					</td>
					<td>
						<a title="View" href="http://www.ogre3d.org/tikiwiki/tiki-download_wiki_attachment.php?attId=48" target="_blank"><img src="test_files/monitor.png" alt="View" style="border: none" title="View" class="icon" width="16" height="16"></a>
						<a title="Download" href="http://www.ogre3d.org/tikiwiki/tiki-download_wiki_attachment.php?attId=48&amp;download=y"><img src="test_files/disk.png" alt="Download" style="border: none" title="Download" class="icon" width="16" height="16"></a>
						&nbsp;
											</td>
					<td><small></small></td>
					<td>
						<small>Thu 20 of May, 2010 21:52 UTC by <a class="link titletips" title="User information - Click for more info|&lt;table&gt;&lt;tr&gt;&lt;td&gt;&lt;img border='0' src='temp/public//avatar_jacmoe.jpg'  alt='jacmoe' /&gt;&lt;/td&gt;&lt;td&gt;Jacob Moen&lt;br /&gt;&lt;img src='img/icons/star_purple.gif' height='11' width='11' alt='180265 points' /&gt;&amp;nbsp;180265&lt;br /&gt;&lt;img src='img/flags/Denmark.gif' /&gt; Denmark&lt;br /&gt;Last seen on Mon 17 of Sep., 2012 [16:36 UTC]&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;" href="http://www.ogre3d.org/tikiwiki/tiki-user_information.php?userId=2"><i class="highlightgroup"><b>jacmoe</b></i></a><img src="test_files/star_purple.gif" alt="180265 points" width="11" height="11">&nbsp;</small>
					</td>
					<td style="text-align:right;">8.76&nbsp;Kb</td>
					<td style="text-align:right;">5386</td>
				</tr>
					</tbody></table>
	
	

	</div>
<a name="comments"></a>

	<div id="comments">
				
	<div id="comzone059fdc27c203b6df159bc0ef6a68ae79" style="display: none;">


	
	

			<form method="get" action="http://www.ogre3d.org/tikiwiki/tiki-index.php" class="comments">
							<input type="hidden" name="page" value="3rd person camera system tutorial">
						<input type="hidden" name="comments_parentId" value="0">    
			<input type="hidden" name="comments_grandParentId" value="">    
			<input type="hidden" name="comments_reply_threadId" value="0">    
			<input type="hidden" name="comments_objectId" value="wiki page:3rd person camera system tutorial">
			<input type="hidden" name="comments_offset" value="0">
															
			
											<div class="forum_actions">
											<div class="headers">
												</div>
					
									</div>
			
							
<div class="post commentStyle_threaded" id="threadId57">
	<div class="inner"><span class="corners-top"><span></span></span>

	<div class="clearfix postbody">
		
<div class="clearfix postbody-title">
				
		<div class="actions">
				
							
							
	  		
			</div>
	
		<div class="checkbox">
			</div>
	
		<div class="title">
	
	</div>
	
		<br class="clear">
</div>		
<div class="clearfix content">

	<div class="clearfix author">

				
		<span class="author_info">

			<span class="author_post_info">
									Posted by <span class="author_post_info_by"><a class="link titletips" title="User information - Click for more info|&lt;img src='img/icons/star_green.gif' height='11' width='11' alt='654 points' /&gt;&amp;nbsp;654&lt;br /&gt;Last seen on Wed 04 of Aug., 2010 [20:30 UTC]&lt;br /&gt;" href="http://www.ogre3d.org/tikiwiki/tiki-user_information.php?userId=138">NIKI_MC</a><img src="test_files/star_green.gif" alt="654 points" width="11" height="11">&nbsp;</span>
													<span class="author_post_info_on">on Sat 10 of July, 2010 22:00 UTC</span>
							</span>
								
						<span class="icons">
			<span class="actions">
									</span>
			<span class="infos">
									</span>
			</span>
							</span>
	</div>

<div class="clearfix postbody-content">
	<p>/* Camera system tutorial by Kencho */
</p>

<ol><li>include "ExampleApplication.h"
</li></ol><p>&nbsp;
<br>// Generic Character class
<br>class Character {
</p>
<p><tt> // Attributes <del>--</del><del>--</del><del>--</del><del>--</del><del>--</del><del>--</del><del>--</del><del>--</del><del>--</del><del>--</del><del>--</del><del>--</del><del>--</del></tt>
</p>
<p><tt>     protected:</tt>
</p>
<p><tt>         SceneNode *mMainNode; // Main character node</tt>
</p>
<p><tt>         SceneNode *mSightNode; // "Sight" node - The character is supposed to be looking here</tt>
</p>
<p><tt>         SceneNode *mCameraNode; // Node for the chase camera</tt>
</p>
<p><tt>         Entity *mEntity; // Character entity</tt>
</p>
<p><tt>         SceneManager *mSceneMgr;</tt>
</p>
<p><tt>     public:</tt>
</p>
<p><tt> // Methods <del>--</del><del>--</del><del>--</del><del>--</del><del>--</del><del>--</del><del>--</del><del>--</del><del>--</del><del>--</del><del>--</del><del>--</del><del>--</del>---</tt>
</p>
<p><tt>     protected:</tt>
</p>
<p><tt>     public:</tt>
</p>
<p><tt>         // Updates the character (movement...)</tt>
</p>
<p><tt>         virtual void update (Real elapsedTime, OIS::Keyboard *input) = 0;</tt>
</p>
<p><tt>         // The three methods below returns the two camera-related nodes,</tt>
</p>
<p><tt>         // and the current position of the character (for the 1st person camera)</tt>
</p>
<p><tt>         SceneNode *getSightNode () {</tt>
</p>
<p><tt>             return mSightNode;</tt>
</p>
<p><tt>         }</tt>
</p>
<p><tt>         SceneNode *getCameraNode () {</tt>
</p>
<p><tt>             return mCameraNode;</tt>
</p>
<p><tt>         }</tt>
</p>
<p><tt>         Vector3 getWorldPosition () {</tt>
</p>
<p><tt>             return mMainNode-&gt;_getDerivedPosition ();</tt>
</p>
<p><tt>         }</tt>
</p>
<p><tt> };</tt>
<br>// Specialization of the Character class - Our dear Ogre <img alt=":-D" title="grinning" src="test_files/icon_biggrin.gif">
</p>
<p><tt> class OgreCharacter : public Character {</tt>
</p>
<p><tt> // Attributes <del>--</del><del>--</del><del>--</del><del>--</del><del>--</del><del>--</del><del>--</del><del>--</del><del>--</del><del>--</del><del>--</del><del>--</del><del>--</del></tt>
</p>
<p><tt>     protected:</tt>
</p>
<p><tt>         String mName;</tt>
</p>
<p><tt>     public:</tt>
</p>
<p><tt> // Methods <del>--</del><del>--</del><del>--</del><del>--</del><del>--</del><del>--</del><del>--</del><del>--</del><del>--</del><del>--</del><del>--</del><del>--</del><del>--</del>---</tt>
</p>
<p><tt>     protected:</tt>
</p>
<p><tt>     public:</tt>
</p>
<p><tt>         OgreCharacter (String name, SceneManager *sceneMgr) {</tt>
</p>
<p><tt>             // Setup basic member references</tt>
</p>
<p><tt>             mName = name;</tt>
</p>
<p><tt>             mSceneMgr = sceneMgr;</tt>
</p>

<p><tt>             // Setup basic node structure to handle 3rd person cameras</tt>
</p>
<p><tt>             mMainNode = mSceneMgr-&gt;getRootSceneNode ()-&gt;createChildSceneNode (mName);</tt>
</p>
<p><tt>             mSightNode = mMainNode-&gt;createChildSceneNode (mName + "_sight", Vector3 (0, 0, 100));</tt>
</p>
<p><tt>             mCameraNode = mMainNode-&gt;createChildSceneNode (mName + "_camera", Vector3 (0, 50, -100));</tt>
</p>

<p><tt>             // Give this character a shape <img alt=":-)" title="smiling" src="test_files/icon_smile.gif"></tt>
</p>
<p><tt>             mEntity = mSceneMgr-&gt;createEntity (mName, "Punk Ball.mesh");</tt>
</p>
<p><tt>             mMainNode-&gt;attachObject (mEntity);</tt>
</p>
<p><tt>         }</tt>
</p>
<p><tt>         ~OgreCharacter () {</tt>
</p>
<p><tt>             mMainNode-&gt;detachAllObjects ();</tt>
</p>
<p><tt>             delete mEntity;</tt>
</p>
<p><tt>             mMainNode-&gt;removeAndDestroyAllChildren ();</tt>
</p>
<p><tt>             mSceneMgr-&gt;destroySceneNode (mName);</tt>
</p>
<p><tt>         }</tt>
</p>

<p><tt>         void update (Real elapsedTime, OIS::Keyboard *input) {</tt>
</p>
<p><tt>             // Handle movement</tt>
</p>
<p><tt>             if (input-&gt;isKeyDown (OIS::KC_W)) {</tt>
</p>
<p><tt>                 mMainNode-&gt;translate (mMainNode-&gt;getOrientation () * Vector3 (0, 0, 100 * elapsedTime));</tt>
</p>
<p><tt>             }</tt>
</p>
<p><tt>             if (input-&gt;isKeyDown (OIS::KC_S)) {</tt>
</p>
<p><tt>                 mMainNode-&gt;translate (mMainNode-&gt;getOrientation () * Vector3 (0, 0, -50 * elapsedTime));</tt>
</p>
<p><tt>             }</tt>
</p>
<p><tt>             if (input-&gt;isKeyDown (OIS::KC_A)) {</tt>
</p>
<p><tt>                 mMainNode-&gt;yaw (Radian (2 * elapsedTime));</tt>
</p>
<p><tt>             }</tt>
</p>
<p><tt>             if (input-&gt;isKeyDown (OIS::KC_D)) {</tt>
</p>
<p><tt>                 mMainNode-&gt;yaw (Radian (-2 * elapsedTime));</tt>
</p>
<p><tt>             }</tt>
</p>
<p><tt>         }</tt>
</p>

<p><tt>         // Change visibility - Useful for 1st person view ;)</tt>
</p>
<p><tt>         void setVisible (bool visible) {</tt>
</p>
<p><tt>             mMainNode-&gt;setVisible (visible);</tt>
</p>
<p><tt>         }</tt>
</p>
<p><tt> };</tt>
</p>

<p><tt> // Our extended camera class</tt>
</p>
<p><tt> class ExtendedCamera {</tt>
</p>
<p><tt> // Attributes <del>--</del><del>--</del><del>--</del><del>--</del><del>--</del><del>--</del><del>--</del><del>--</del><del>--</del><del>--</del><del>--</del><del>--</del><del>--</del></tt>
</p>
<p><tt>     protected:</tt>
</p>
<p><tt>         SceneNode *mTargetNode; // The camera target</tt>
</p>
<p><tt>         SceneNode *mCameraNode; // The camera itself</tt>
</p>
<p><tt>         Camera *mCamera; // Ogre camera</tt>
</p>

<p><tt>         SceneManager *mSceneMgr;</tt>
</p>
<p><tt>         String mName;</tt>
</p>

<p><tt>         bool mOwnCamera; // To know if the ogre camera binded has been created outside or inside of this class</tt>
</p>

<p><tt>         Real mTightness; // Determines the movement of the camera - 1 means tight movement, while 0 means no movement</tt>
</p>
<p><tt>     public:</tt>
</p>
<p><tt> // Methods <del>--</del><del>--</del><del>--</del><del>--</del><del>--</del><del>--</del><del>--</del><del>--</del><del>--</del><del>--</del><del>--</del><del>--</del><del>--</del>---</tt>
</p>
<p><tt>     protected:</tt>
</p>
<p><tt>     public:</tt>
</p>
<p><tt>         ExtendedCamera (String name, SceneManager *sceneMgr, Camera *camera = 0) {</tt>
</p>
<p><tt>             // Basic member references setup</tt>
</p>
<p><tt>             mName = name;</tt>
</p>
<p><tt>             mSceneMgr = sceneMgr;</tt>
</p>

<p><tt>             // Create the camera's node structure</tt>
</p>
<p><tt>             mCameraNode = mSceneMgr-&gt;getRootSceneNode ()-&gt;createChildSceneNode (mName);</tt>
</p>
<p><tt>             mTargetNode = mSceneMgr-&gt;getRootSceneNode ()-&gt;createChildSceneNode (mName + "_target");</tt>
</p>
<p><tt>             mCameraNode-&gt;setAutoTracking (true, mTargetNode); // The camera will always look at the camera target</tt>
</p>
<p><tt>             mCameraNode-&gt;setFixedYawAxis (true); // Needed because of auto tracking</tt>
</p>

<p><tt>             // Create our camera if it wasn't passed as a parameter</tt>
</p>
<p><tt>             if (camera == 0) {</tt>
</p>
<p><tt>                 mCamera = mSceneMgr-&gt;createCamera (mName);</tt>
</p>
<p><tt>                 mOwnCamera = true;</tt>
</p>
<p><tt>             }</tt>
</p>
<p><tt>             else {</tt>
</p>
<p><tt>                 mCamera = camera;</tt>
</p>
<p><tt>                                 // just to make sure that mCamera is set to 'origin' (same position as the mCameraNode)</tt>
</p>
<p><tt>                                 mCamera-&gt;setPosition(0.0,0.0,0.0);</tt>
</p>
<p><tt>                 mOwnCamera = false;</tt>
</p>
<p><tt>             }</tt>
</p>
<p><tt>             // ... and attach the Ogre camera to the camera node</tt>
</p>
<p><tt>             mCameraNode-&gt;attachObject (mCamera);</tt>
</p>

<p><tt>             // Default tightness</tt>
</p>
<p><tt>             mTightness = 0.01f;</tt>
</p>
<p><tt>         }</tt>
</p>
<p><tt>         ~ExtendedCamera () {</tt>
</p>
<p><tt>             mCameraNode-&gt;detachAllObjects ();</tt>
</p>
<p><tt>             if (mOwnCamera)</tt>
</p>
<p><tt>                 delete mCamera;</tt>
</p>
<p><tt>             mSceneMgr-&gt;destroySceneNode (mName);</tt>
</p>
<p><tt>             mSceneMgr-&gt;destroySceneNode (mName + "_target");</tt>
</p>
<p><tt>         }</tt>
</p>

<p><tt>         void setTightness (Real tightness) {</tt>
</p>
<p><tt>             mTightness = tightness;</tt>
</p>
<p><tt>         }</tt>
</p>

<p><tt>         Real getTightness () {</tt>
</p>
<p><tt>             return mTightness;</tt>
</p>
<p><tt>         }</tt>
</p>

<p><tt>         Vector3 getCameraPosition () {</tt>
</p>
<p><tt>             return mCameraNode-&gt;getPosition ();</tt>
</p>
<p><tt>         }</tt>
</p>

<p><tt>         void instantUpdate (Vector3 cameraPosition, Vector3 targetPosition) {</tt>
</p>
<p><tt>             mCameraNode-&gt;setPosition (cameraPosition);</tt>
</p>
<p><tt>             mTargetNode-&gt;setPosition (targetPosition);</tt>
</p>
<p><tt>         }</tt>
</p>

<p><tt>         void update (Real elapsedTime, Vector3 cameraPosition, Vector3 targetPosition) {</tt>
</p>
<p><tt>             // Handle movement</tt>
</p>
<p><tt>             Vector3 displacement;</tt>
</p>

<p><tt>             displacement = (cameraPosition - mCameraNode-&gt;getPosition ()) * mTightness;</tt>
</p>
<p><tt>             mCameraNode-&gt;translate (displacement);</tt>
</p>

<p><tt>             displacement = (targetPosition - mTargetNode-&gt;getPosition ()) * mTightness;</tt>
</p>
<p><tt>             mTargetNode-&gt;translate (displacement);</tt>
</p>
<p><tt>         }</tt>
</p>
<p><tt> };</tt>
</p>

<p><tt> class SampleListener : public ExampleFrameListener</tt>
</p>
<p><tt> {</tt>
</p>
<p><tt> protected:</tt>
</p>
<p><tt>     // References to the main character and the camera</tt>
</p>
<p><tt>     Character *mChar;</tt>
</p>
<p><tt>     ExtendedCamera *mExCamera;</tt>
</p>

<p><tt>     // Camera mode - Now supports 1st person, 3rd person (chasing) and 3rd person (fixed)</tt>
</p>
<p><tt>     unsigned int mMode;</tt>
</p>

<p><tt> public:</tt>
</p>
<p><tt>     SampleListener(RenderWindow* win, Camera* cam)</tt>
</p>
<p><tt>     : ExampleFrameListener(win, cam)</tt>
</p>
<p><tt>     {</tt>
</p>
<p><tt>         mChar = 0;</tt>
</p>
<p><tt>         mExCamera = 0;</tt>
</p>
<p><tt>         mMode = 0;</tt>
</p>
<p><tt>     }</tt>
</p>

<p><tt>     void setCharacter (Character *character) {</tt>
</p>
<p><tt>         mChar = character;</tt>
</p>
<p><tt>     }</tt>
</p>

<p><tt>     void setExtendedCamera (ExtendedCamera *cam) {</tt>
</p>
<p><tt>         mExCamera = cam;</tt>
</p>
<p><tt>     }</tt>
</p>

<p><tt>     bool frameStarted(const FrameEvent&amp; evt)</tt>
</p>
<p><tt>     {</tt>
</p>
<p><tt>         mKeyboard-&gt;capture();</tt>
</p>

<p><tt>         if (mChar) {</tt>
</p>
<p><tt>             mChar-&gt;update (evt.timeSinceLastFrame, mKeyboard);</tt>
</p>

<p><tt>             if (mExCamera) {</tt>
</p>
<p><tt>                 switch (mMode) {</tt>
</p>
<p><tt>                     case 0: // 3rd person chase</tt>
</p>
<p><tt>                         mExCamera-&gt;update (evt.timeSinceLastFrame,</tt>
</p>
<p><tt>                                             mChar-&gt;getCameraNode ()-&gt;_getDerivedPosition(),</tt>
</p>
<p><tt>                                             mChar-&gt;getSightNode ()-&gt;_getDerivedPosition() );</tt>
</p>
<p><tt>                         break;</tt>
</p>
<p><tt>                     case 1: // 3rd person fixed</tt>
</p>
<p><tt>                         mExCamera-&gt;update (evt.timeSinceLastFrame,</tt>
</p>
<p><tt>                                             Vector3 (0, 200, 0),</tt>
</p>
<p><tt>                                             mChar-&gt;getSightNode ()-&gt;_getDerivedPosition() );</tt>
</p>
<p><tt>                         break;</tt>
</p>
<p><tt>                     case 2: // 1st person</tt>
</p>
<p><tt>                         //mChar-&gt;getWorldPosition ()</tt>
<br>						 mExCamera-&gt;update (evt.timeSinceLastFrame,
</p>
<p><tt>                                             mChar-&gt;getWorldPosition (),</tt>
</p>
<p><tt>                                             mChar-&gt;getSightNode ()-&gt;_getDerivedPosition() );</tt>
</p>
<p><tt>                         break;</tt>
</p>
<p><tt>                 }</tt>
</p>
<p><tt>             }</tt>
</p>
<p><tt>         }</tt>
</p>

<p><tt>         // 3rd Person - Chase Camera</tt>
</p>
<p><tt>         if (mKeyboard-&gt;isKeyDown (OIS::KC_F1)) {</tt>
</p>
<p><tt>             mMode = 0;</tt>
</p>
<p><tt>             if (mChar)</tt>
</p>
<p><tt>                 static_cast(mChar)-&gt;setVisible (true);</tt>
</p>
<p><tt>             if (mExCamera) {</tt>
</p>
<p><tt>                 if (mChar)</tt>
</p>
<p><tt>                     mExCamera-&gt;instantUpdate 
(mChar-&gt;getCameraNode ()-&gt;_getDerivedPosition() , 
mChar-&gt;getSightNode ()-&gt;_getDerivedPosition() );</tt>
</p>
<p><tt>                 mExCamera-&gt;setTightness (0.01f);</tt>
</p>
<p><tt>             }</tt>
</p>
<p><tt>          }</tt>
</p>
<p><tt>         // 3rd Person - Fixed Camera</tt>
</p>
<p><tt>         if (mKeyboard-&gt;isKeyDown (OIS::KC_F2)) {</tt>
</p>
<p><tt>             mMode = 1;</tt>
</p>
<p><tt>             if (mChar)</tt>
</p>
<p><tt>                 static_cast(mChar)-&gt;setVisible (true);</tt>
</p>
<p><tt>             if (mExCamera) {</tt>
</p>
<p><tt>                 if (mChar)</tt>
</p>
<p><tt>                     mExCamera-&gt;instantUpdate (Vector3 (0, 200, 0), mChar-&gt;getSightNode ()-&gt;_getDerivedPosition() );</tt>
</p>
<p><tt>                 mExCamera-&gt;setTightness (0.01f);</tt>
</p>
<p><tt>             }</tt>
</p>
<p><tt>         }</tt>
</p>
<p><tt>         // 1st Person</tt>
</p>
<p><tt>         if (mKeyboard-&gt;isKeyDown (OIS::KC_F3))  {</tt>
</p>
<p><tt>             mMode = 2;</tt>
</p>
<p><tt>             if (mChar)</tt>
</p>
<p><tt>                 static_cast(mChar)-&gt;setVisible (false);</tt>
</p>
<p><tt>             if (mExCamera) {</tt>
</p>
<p><tt>                 if (mChar)</tt>
</p>
<p><tt>                     mExCamera-&gt;instantUpdate 
(mChar-&gt;getWorldPosition (), mChar-&gt;getSightNode 
()-&gt;_getDerivedPosition() );</tt>
</p>
<p><tt>                 mExCamera-&gt;setTightness (1.0f);</tt>
</p>
<p><tt>             }</tt>
</p>
<p><tt>         }</tt>
</p>

<p><tt>         // Exit if we press Esc</tt>
</p>
<p><tt>         if(mKeyboard-&gt;isKeyDown (OIS::KC_ESCAPE))</tt>
</p>
<p><tt>             return false;</tt>
</p>

<p><tt>         return true;</tt>
</p>
<p><tt>     }</tt>
</p>
<p><tt> };</tt>
</p>

<p><tt> class SampleApplication : public ExampleApplication</tt>
</p>
<p><tt> {</tt>
</p>
<p><tt> protected:</tt>
</p>
<p><tt> public:</tt>
</p>
<p><tt>     SampleApplication()</tt>
</p>
<p><tt>     {</tt>
</p>
<p><tt>     }</tt>
</p>
<p><tt>     ~SampleApplication()</tt>
</p>
<p><tt>     {</tt>
</p>
<p><tt>     }</tt>
</p>

<p><tt> protected:</tt>
</p>
<p><tt>     // Just override the mandatory create scene method</tt>
</p>
<p><tt>     void createScene(void)</tt>
</p>
<p><tt>     {</tt>
</p>
<p><tt>         // Set ambient light</tt>
</p>
<p><tt>         mSceneMgr-&gt;setAmbientLight(ColourValue(0.2, 0.2, 0.2));</tt>
</p>

<p><tt>         // LIGHTS!!</tt>
</p>
<p><tt>         // Create a point light</tt>
</p>
<p><tt>         Light* l = mSceneMgr-&gt;createLight("MainLight");</tt>
</p>
<p><tt>         // Accept default settings: point light, white diffuse, just set position</tt>
</p>
<p><tt>         // NB I could attach the light to a SceneNode if I wanted it to move automatically with</tt>
</p>
<p><tt>         //  other objects, but I don't</tt>
</p>
<p><tt>         l-&gt;setType(Light::LT_DIRECTIONAL);</tt>
</p>
<p><tt>         l-&gt;setDirection(-0.5, -0.5, 0);</tt>
</p>

<p><tt>         // CAMERA!!</tt>
</p>
<p><tt>         mCamera-&gt;setPosition (0, 0, 0);    // Required or else the camera will have an offset</tt>
</p>

<p><tt>         // ACTION!!!</tt>
</p>
<p><tt>         // Fill the scene with some razors</tt>
</p>
<p><tt>         SceneNode *razorNode;</tt>
</p>
<p><tt>         Entity *razorEntity;</tt>
</p>
<p><tt>         for (unsigned int i = 0; i &lt; 30; ++i) {</tt>
</p>
<p><tt>             razorNode = mSceneMgr-&gt;getRootSceneNode 
()-&gt;createChildSceneNode (StringConverter::toString (i), Vector3 
(Math::RangeRandom (-1000, 1000), 0, Math::RangeRandom (-1000, 1000)));</tt>
</p>
<p><tt>             razorEntity = mSceneMgr-&gt;createEntity (StringConverter::toString (i), "razor.mesh");</tt>
</p>
<p><tt>             razorNode-&gt;attachObject (razorEntity);</tt>
</p>
<p><tt>         }</tt>
</p>

<p><tt>         // Main character</tt>
</p>
<p><tt>         OgreCharacter *ogre = new OgreCharacter ("Ogre 1", mSceneMgr);</tt>
</p>
<p><tt>         ExtendedCamera *exCamera = new ExtendedCamera ("Extended Camera", mSceneMgr, mCamera);</tt>
</p>

<p><tt>         // Frame listener to manage both character and camera updating and different camera modes</tt>
</p>
<p><tt>         // Need to create it here as we want to change some parameters here, thus avoiding defining</tt>
</p>
<p><tt>         // ogre and exCamera as member variables</tt>
</p>
<p><tt>         mFrameListener = new SampleListener (mWindow, mCamera);</tt>
</p>
<p><tt>         static_cast(mFrameListener)-&gt;setCharacter (ogre);</tt>
</p>
<p><tt>         static_cast(mFrameListener)-&gt;setExtendedCamera (exCamera);</tt>
</p>
<p><tt>     }</tt>
</p>
<p><tt>     void destroyScene(void)</tt>
</p>
<p><tt>     {</tt>
</p>
<p><tt>     }</tt>
</p>
<p><tt>     void createFrameListener(void)</tt>
</p>
<p><tt>     {</tt>
</p>
<p><tt>         // This is where we instantiate our own frame listener</tt>
</p>
<p><tt> //        mFrameListener= new SampleListener(mWindow, mCamera);</tt>
</p>
<p><tt>         mRoot-&gt;addFrameListener(mFrameListener);</tt>
</p>
<p><tt>     }</tt>
</p>
<p><tt> };</tt>
</p>
<ol><li>if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
</li></ol><p><tt> #define WIN32_LEAN_AND_MEAN</tt>
</p>
<p><tt> #include "windows.h"</tt>
</p>

<p><tt> INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )</tt>
</p>
<p><tt> #else</tt>
</p>
<p><tt> int main(int argc, char **argv)</tt>
</p>
<p><tt> #endif</tt>
</p>
<p><tt> {</tt>
</p>
<p><tt>    // Create application object</tt>
</p>
<p><tt>    SampleApplication app;</tt>
</p>

<p><tt>    try {</tt>
</p>
<p><tt>        app.go();</tt>
</p>
<p><tt>    } catch( Exception&amp; e ) {</tt>
</p>
<p><tt> #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32</tt>
</p>
<p><tt>        MessageBox( NULL, e.getFullDescription().c_str(), "An 
exception has occured!", MB_OK |      MB_IConerror | MB_TASKMODAL);</tt>
</p>
<p><tt> #else</tt>
</p>
<p><tt>        fprintf(stderr, "An exception has occured: %s\n",</tt>
</p>
<p><tt>                e.getFullDescription().c_str());</tt>
</p>
<p><tt> #endif</tt>
</p>
<p><tt>    }</tt>
</p>

<p><tt>    return 0;</tt>
</p>
<p><tt> }</tt>
</p>

	
</div>

</div>

	</div>

	
<div class="postfooter">
	<div class="status">
			
			<span class="back_to_top"><a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=3rd+person+camera+system+tutorial&amp;structure=Tutorials#tiki-top" title="top of page"><img src="test_files/resultset_up.png" alt="top of page" style="border: none" title="top of page" class="icon" width="16" height="16"></a></span>
	
	</div>

		<div class="actions">
			</div>
	
</div>	<br style="clear: both;">

	<span class="corners-bottom"><span></span></span></div>
</div>

				<br>															</form>

		<div class="thread_pagination">
			
					</div> 
	 



</div>


</div><!-- comzone end -->	
</div>

<div class="help" id="tikihelp">
	<div class="help_sections ui-tabs ui-widget ui-widget-content ui-corner-all" id="help_sections" style="display:none">
		<ul class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">
							<li class="ui-state-default ui-corner-top ui-tabs-selected ui-state-active">
					<a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=3rd+person+camera+system+tutorial&amp;structure=Tutorials#advanced_search_help">
						Search Help
					</a>
				</li>
					</ul>
					<div id="advanced_search_help" class="ui-tabs-panel ui-widget-content ui-corner-bottom">
										
<h3>Non Advanced Search or Natural Search</h3><div class="help_section">The documents are returned sorted on relevance depending on order, proximity, frequency of terms.</div><h3>Advanced Search or Boolean Search</h3><div class="help_section"><h4>Default search behavior</h4><p>By default, all search terms are <em>optional</em>.&nbsp;It
 behaves like an OR logic.&nbsp;Objects that contain the more terms are 
rated higher in the results and will appear first in their type. For 
example, <strong>wiki forum</strong> will find:</p><ul><li>objects that include both terms</li><li>objects that include the term <strong>wiki</strong></li><li>objects that include the term <strong>forum</strong></li></ul><h4>Requiring terms</h4><p>Add a plus sign ( + ) before a term to indicate that the term <em>must</em> appear in results.&nbsp;Example: <strong>+wiki forum</strong> will find objects containing at least <strong>wiki</strong>. Objects with both terms and many occurences of the terms will appear first.</p><h4 id="excluding">Excluding terms</h4><p>Add a minus sign ( - ) before a term to indicate that the term <em>must not</em> appear in the results.&nbsp;To reduce a term's value without completely excluding it, <a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=3rd+person+camera+system+tutorial&amp;structure=Tutorials#reducing" title="Reducing a term's value">use a tilde</a>.&nbsp;Example: <strong>-wiki forum</strong> will find objects that do not contain <strong>wiki</strong> but contain <strong>forum</strong></p><h4>Grouping terms</h4><p>Use parenthesis ( ) to group terms into subexpressions.&nbsp;Example: <strong>+wiki +(forum blog)</strong> will find objects that contain <strong>wiki</strong> and <strong>forum</strong> or that contain <strong>wiki</strong> and <strong>blog</strong> in any order.</p><h4>Finding phrases</h4><p>Use double quotes ( " " ) around a phrase to find terms in the exact order, exactly as typed.&nbsp;Example: <strong>"Alex Bell"</strong> will not find <strong>Bell Alex</strong> or <strong>Alex G. Bell</strong>. </p><h4>Using wildcards</h4><p>Add an asterisk ( * ) after a term to find objects that include the root word. For example, <strong>run*</strong> will find:</p><ul><li>objects that include the term <strong>run</strong></li><li>objects that include the term <strong>runner</strong></li><li>objects that include the term <strong>running</strong></li></ul><h4 id="reducing">Reducing a term's value</h4><p>Add
 a tilde ( ~ ) before a term to reduce its value indicate to the ranking
 of the results.&nbsp;Objects that contain the term will appear lower 
than other objects (unlike the <a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=3rd+person+camera+system+tutorial&amp;structure=Tutorials#excluding" title="Excluding terms">minus sign</a>	which will completely exclude a term).&nbsp;Example: <strong>+wiki ~forum</strong> will rate an object with only <strong>wiki</strong> higher that an object with <strong>wiki</strong> and  <strong>forum</strong>.</p><h4>Changing relevance value</h4><p>Add
 a less than ( &lt; ) or greater than ( &gt; ) sign before a term to 
change the term's contribution to the overall relevance value assigned 
to a object.&nbsp;Example: <strong>+wiki +(&gt;forum &lt; blog)</strong> will find objects that contain <strong>wiki</strong> and <strong>forum</strong> or <strong>wiki</strong> and <strong>blog</strong> in any order. <strong>wiki forum</strong> will be rated higher.</p></div>		
		
			</div>
			</div>
	</div>
							</div><a href="javascript:toggle('wpfade-1')">Click this link to toggle the Report Page Issue Form</a><div id="wpfade-1" style="display:none"><b>You do not have permission to insert an item</b>
</div>
</div>						</div>
					</div>

					<hr class="hidden">
					</div>
					<div class="clearfix" id="col3" style="display: table-cell;">
					<h2 class="hidden">Sidebar</h2>
					<div class="content">
							


<div class="box-shadow">	<div class="box box-SearchTags cssmenubox">
			<h3 class="box-title clearfix">
						<span class="moduletitle">Search by Tags
</span>
						<!--[if IE]><br class="clear" style="height: 1px !important" /><![endif]--></h3>
			<div id="mod-SearchTagsr0" style="display: block" class="clearfix box-data">

<div id="SearchTags" style="display:block;">
<div class="role_navigation">
			<ul id="cssmenu0" class="cssmenu menu51"><li class="option405 menuOption menuLevel0"><a href="http://www.ogre3d.org/tikiwiki/tiki-browse_freetags.php"><span class="menuText">Search Wiki by Freetags</span></a></li></ul>
</div>
</div>


		</div>
		<div class="box-footer">

		</div>
	</div>
</div>
					



<div class="box-shadow">	<div class="box box-last_modif_pages">
			<h3 class="box-title clearfix">
						<span class="moduletitle">Last changes</span>
							<span class="moduleflip" id="moduleflip-last_modif_pagesr6">
				<a title="Toggle module contents" class="flipmodtitle" href="javascript:icntoggle('mod-last_modif_pagesr6','module.png');">
										<img src="test_files/module.png" alt="[toggle]" id="icnmod-last_modif_pagesr6" class="flipmodimage" style="border: none" title="[toggle]" width="16" height="16">
				</a>
			</span>
							<!--[if IE]><br class="clear" style="height: 1px !important" /><![endif]--></h3>
			<div id="mod-last_modif_pagesr6" style="display: block" class="clearfix box-data">
<ol>			<li>
			<a class="linkmodule" href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Easy+Ogre+Exporter" title="Fri 16 of Sep., 2016 22:52 UTC, by arkeon">
							Easy Ogre Exporter
						</a>
		</li>
			<li>
			<a class="linkmodule" href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Advanced+Mogre+Framework" title="Wed 14 of Sep., 2016 10:51 UTC, by randomcode">
							Advanced Mogre Framework
						</a>
		</li>
			<li>
			<a class="linkmodule" href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Ogre+2.1+FAQ" title="Thu 08 of Sep., 2016 23:37 UTC, by dark_sylinc">
							Ogre 2.1 FAQ
						</a>
		</li>
			<li>
			<a class="linkmodule" href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Ogre3D+Steam+Games+Sales+Charts" title="Fri 02 of Sep., 2016 17:06 UTC, by ericb">
							Ogre3D Steam Games Sales Charts
						</a>
		</li>
			<li>
			<a class="linkmodule" href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=HDR+%28High+Dynamic+Range%29" title="Tue 30 of Aug., 2016 16:19 UTC, by dark_sylinc">
							HDR (High Dynamic Range)
						</a>
		</li>
			<li>
			<a class="linkmodule" href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=OgreArticles" title="Tue 30 of Aug., 2016 15:07 UTC, by dark_sylinc">
							OgreArticles
						</a>
		</li>
			<li>
			<a class="linkmodule" href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Roadmap" title="Sun 28 of Aug., 2016 17:47 UTC, by spacegaier">
							Roadmap
						</a>
		</li>
			<li>
			<a class="linkmodule" href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=TindalosNotes" title="Sat 27 of Aug., 2016 23:17 UTC, by dark_sylinc">
							TindalosNotes
						</a>
		</li>
			<li>
			<a class="linkmodule" href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Mogre+HOWTO%27s+and+Snippets" title="Mon 22 of Aug., 2016 08:48 UTC, by randomcode">
							Mogre HOWTO's and Snippets
						</a>
		</li>
			<li>
			<a class="linkmodule" href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=MOGRE+dotSceneLoader" title="Thu 18 of Aug., 2016 09:11 UTC, by spacegaier">
							MOGRE dotSceneLoader
						</a>
		</li>
	</ol><a class="linkmodule" style="margin-left: 20px" href="http://www.ogre3d.org/tikiwiki/tiki-lastchanges.php">...more</a>



		</div>
		<div class="box-footer">

		</div>
	</div>
</div>
					



<div class="box-shadow">	<div class="box box-search_box">
			<h3 class="box-title clearfix">
						<span class="moduletitle">Search box</span>
							<span class="moduleflip" id="moduleflip-search_boxr6">
				<a title="Toggle module contents" class="flipmodtitle" href="javascript:icntoggle('mod-search_boxr6','module.png');">
										<img src="test_files/module.png" alt="[toggle]" id="icnmod-search_boxr6" class="flipmodimage" style="border: none" title="[toggle]" width="16" height="16">
				</a>
			</span>
							<!--[if IE]><br class="clear" style="height: 1px !important" /><![endif]--></h3>
			<div id="mod-search_boxr6" style="display: block" class="clearfix box-data">
    <form class="forms" id="search-module-form" method="get" action="http://www.ogre3d.org/tikiwiki/tiki-searchresults.php">
    <input id="fuser" name="highlight" size="14" type="text" accesskey="s"> 
		
 			<input type="hidden" name="where" value="wikis">
    			<br><label for="boolean">Advanced search:<input type="checkbox" id="boolean" name="boolean" checked="checked"></label>

				<a onclick="openEditHelp();return false;" href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=3rd+person+camera+system+tutorial"><img src="test_files/help.png" alt="Click for Help" style="border: none" title="Click for Help" class="icon" width="16" height="16"></a><br>
	    <input type="submit" class="wikiaction" name="search" value="Go"> 
    </form>



		</div>
		<div class="box-footer">

		</div>
	</div>
</div>
					



<div class="box-shadow">	<div class="box box-who_is_there">
			<h3 class="box-title clearfix">
						<span class="moduletitle">Online users</span>
							<span class="moduleflip" id="moduleflip-who_is_therer7">
				<a title="Toggle module contents" class="flipmodtitle" href="javascript:icntoggle('mod-who_is_therer7','module.png');">
										<img src="test_files/module.png" alt="[toggle]" id="icnmod-who_is_therer7" class="flipmodimage" style="border: none" title="[toggle]" width="16" height="16">
				</a>
			</span>
							<!--[if IE]><br class="clear" style="height: 1px !important" /><![endif]--></h3>
			<div id="mod-who_is_therer7" style="display: block" class="clearfix box-data">
<div>
23 
online users
</div>



		</div>
		<div class="box-footer">

		</div>
	</div>
</div>
							</div>
				</div>
				<br style="clear:both">
			<!--[if IE 7]><br style="clear:both; height: 0" /><![endif]-->
			</div></div>
				<div id="footer-shadow"><div id="footer">
				<div class="footerbgtrap">
					<div class="content">
		
	<div id="power_icons">
	<br>
<a href="http://www.ogre3d.org/"><img src="test_files/ogre_logo.png" alt="Ogre3d.org" title="Go to Ogre3d.org" border="0"></a>
<br><br>
<span id="poweredby">Powered by</span> <a href="http://info.tikiwiki.org/" title="© 2002–2010 The TikiWiki Community">Tiki Wiki CMS Groupware</a>
</div>


 					</div>
				</div>
			</div></div>	
		</div></div>	</div> 



	
	
	
		
<!-- Put JS at the end -->
	
<!-- jsfile external -->
<!-- jsfile dynamic -->
<script type="text/javascript" src="test_files/tiki-jsplugin.txt"></script>
<!-- jsfile 0 -->
<script type="text/javascript" src="test_files/minified_7e70dc0e4dc84c147ac9fc9af11bcea9.js"></script>


	
<script type="text/javascript">
<!--//--><![CDATA[//><!--
// js 0 
var tiki_cookie_jar=new Array();

function inArray(item, array) {
    for (var i in array) {
        if (array[i] === item) {
            return i;
        }
    }
    return false;
}
var allTimeZoneCodes = ["ACST","ACT","ADDT","ADMT","ADT","AFT","AHDT","AHST","AKDT","AKST","AKTST","AKTT","ALMST","ALMT","AMST","AMT","ANAST","ANAT","ANT","AOT","APT","AQTST","AQTT","ARST","ART","ASHST","ASHT","AST","AWT","AZOMT","AZOST","AZOT","AZST","AZT","BAKST","BAKT","BDST","BDT","BEAT","BEAUT","BMT","BNT","BORTST","BORT","BOST","BOT","BRST","BRT","BST","BTT","BURT","CANT","CAPT","CAST","CAT","CAWT","CCT","CDDT","CDT","CEMT","CEST","CET","CGST","CGT","CHADT","CHAST","CHAT","CHDT","CHOST","CHOT","CHUT","CIT","CJT","CKHST","CKT","CLST","CLT","CMT","COST","COT","CPT","CST","CUT","CVST","CVT","CWST","CWT","CXT","CHST","DACT","DAVT","DDUT","DMT","DUSST","DUST","EASST","EAST","EAT","ECT","EDDT","EDT","EEST","EET","EGST","EGT","EHDT","EIT","EMT","EPT","EST","EWT","FFMT","FJST","FJT","FKST","FKT","FMT","FNST","FNT","FORT","FRUST","FRUT","GALT","GAMT","GBGT","GEST","GET","GFT","GHST","GILT","GMT","GST","GYT","HADT","HAST","HDT","HKST","HKT","HMT","HOVST","HOVT","HPT","HST","HWT","ICT","IDDT","IDT","IHST","IMT","IOT","IRDT","IRKST","IRKT","IRST","ISST","IST","JAVT","JDT","JMT","JST","KART","KAST","KDT","KGST","KGT","KIZST","KIZT","KMT","KOST","KRAST","KRAT","KST","KUYST","KUYT","KWAT","LHST","LINT","LKT","LMT","LONT","LRT","LST","MADMT","MADST","MADT","MAGST","MAGT","MALST","MALT","MART","MAWT","MDDT","MDST","MDT","MEST","MET","MHT","MIST","MMT","MOST","MOT","MPT","MSD","MSK","MST","MUST","MUT","MVT","MWT","MYT","NCST","NCT","NDDT","NDT","NEGT","NEST","NET","NFT","NMT","NOVST","NOVT","NPT","NRT","NST","NUT","NWT","NZDT","NZMT","NZST","OMSST","OMST","ORAST","ORAT","PDDT","PDT","PEST","PETST","PETT","PET","PGT","PHOT","PHST","PHT","PKST","PKT","PMDT","PMST","PMT","PNT","PONT","PPMT","PPT","PST","PWT","PYST","PYT","QMT","QYZST","QYZT","RET","RMT","ROTT","SAKST","SAKT","SAMST","SAMT","SAST","SBT","SCT","SDMT","SGT","SHEST","SHET","SJMT","SLST","SMT","SRT","SST","STAT","SVEST","SVET","SWAT","SYOT","TAHT","TASST","TAST","TBIST","TBIT","TBMT","TFT","TJT","TKT","TLT","TMT","TOST","TOT","TRST","TRT","TSAT","TVT","UCT","ULAST","ULAT","URAST","URAT","URUT","UTC","UYHST","UYST","UYT","UZST","UZT","VET","VLASST","VLAST","VLAT","VOLST","VOLT","VOST","VUST","VUT","WAKT","WARST","WART","WAST","WAT","WEMT","WEST","WET","WFT","WGST","WGT","WIT","WMT","WSDT","WST","YAKST","YAKT","YDDT","YDT","YEKST","YEKT","YERST","YERT","YPT","YST","YWT","A","B","C","D","E","F","G","H","I","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","ZZZ","Z"];
var local_tz = "";
var now = new Date();
var now_string = now.toString();
var m = now_string.match(/[ \(]([A-Z]{3,6})[ \)]?[ \d]*$/);	// try three or more char tz first at the end or just before the year
if (!m) {
	m = now_string.match(/[ \(]([A-Z]{1,6})[ \)]?[ \d]*$/);	// might be a "military" one if not
}
if (m) {
	m = m[1];
} else {	// IE (sometimes) gives UTC +offset instead of the abbreviation
	// sadly this workaround will fail for non-whole hour offsets
	var hours = - now.getTimezoneOffset() / 60;
	m = "GMT" + (hours > 0 ? "+" : "") + hours;
}
if (inArray(m, allTimeZoneCodes)) {
	local_tz = m;
} else {
	local_tz = "UTC";
}
setCookie("local_tz", local_tz);


var openEditHelp = function() {
	var opts, edithelp_pos = getCookie("edithelp_position");
	opts = { width: 460, height: 500, title: "Help", autoOpen: false, beforeclose: function(event, ui) {
		var off = $(this).offsetParent().offset();
   		setCookie("edithelp_position", parseInt(off.left,10) + "," + parseInt(off.top,10) + "," + $(this).offsetParent().width() + "," + $(this).offsetParent().height());
	}};
	if (edithelp_pos) {edithelp_pos = edithelp_pos.split(",");}
	if (edithelp_pos && edithelp_pos.length) {
		opts["position"] = [parseInt(edithelp_pos[0],10), parseInt(edithelp_pos[1],10)];
		opts["width"] = parseInt(edithelp_pos[2],10);
		opts["height"] = parseInt(edithelp_pos[3],10);
	}
	try {
		if ($("#help_sections").dialog) {
			$("#help_sections").dialog("destroy");
		}
	} catch( e ) {
		// IE throws errors destroying a non-existant dialog
	}
	$("#help_sections").dialog(opts).dialog("open");
	
};
// js 100 

// JS Object to hold prefs for jq
var jqueryTiki = new Object();
jqueryTiki.ui = true;
jqueryTiki.ui_theme = "smoothness";
jqueryTiki.tooltips = true;
jqueryTiki.autocomplete = true;
jqueryTiki.superfish = true;
jqueryTiki.replection = false;
jqueryTiki.tablesorter = true;
jqueryTiki.colorbox = true;
jqueryTiki.cboxCurrent = "{current} / {total}";
jqueryTiki.sheet = false;
jqueryTiki.carousel = false;
jqueryTiki.jqs5 = false;
jqueryTiki.validate = true;

jqueryTiki.effect = "";				// Default effect
jqueryTiki.effect_direction = "vertical";	// "horizontal" | "vertical" etc
jqueryTiki.effect_speed = 400;	// "slow" | "normal" | "fast" | milliseconds (int) ]
jqueryTiki.effect_tabs = "slide";		// Different effect for tabs
jqueryTiki.effect_tabs_direction = "vertical";
jqueryTiki.effect_tabs_speed = "fast";

jqueryTiki.autosave = true;
jqueryTiki.sefurl = false;


//--><!]]>
</script>
<script type="text/javascript">
<!--//--><![CDATA[//><!--
$(document).ready(function(){
// jq_onready 0 
phplayersmenu_loaded = 1;

					$('.postbody dt:contains("note")')
						.closest('.postbody')
						.addnotes( $('#top') );
				
 $(function() {$("#help_sections").tabs({});}); 
});
//--><!]]>
</script>

	
</body></html>